Center scrolled view

This commit is contained in:
Kenox 2022-11-03 19:03:20 +01:00
commit 2ffc0d9e6b
3 changed files with 11 additions and 10 deletions

View file

@ -185,6 +185,16 @@ haste.prototype.addLineNumbers = function(lineCount) {
div.appendChild(text); div.appendChild(text);
document.body.appendChild(div) document.body.appendChild(div)
} }
if(window.location.hash) {
const hash = window.location.hash.substring(1);
highlightLine(hash)
console.log("try to get to line" + hash);
document.getElementById("line" + hash)[0].scrollIntoView({
behavior: 'smooth',
block: 'center'
});
}
}; };
function highlightLine(line) { function highlightLine(line) {

File diff suppressed because one or more lines are too long

View file

@ -21,15 +21,6 @@
if (path === '/') { app.newDocument(true); } if (path === '/') { app.newDocument(true); }
else { app.loadDocument(path.substring(1, path.length)); else { app.loadDocument(path.substring(1, path.length));
} }
if(window.location.hash) {
const hash = window.location.hash.substring(1);
highlightLine(hash)
document.getElementById("line" + hash)[0].scrollIntoView({
behavior: 'smooth',
block: 'center'
});
}
}; };
// Set up the pop state to handle loads, skipping the first load // Set up the pop state to handle loads, skipping the first load
// to make chrome behave like others: // to make chrome behave like others: