Center scrolled view

This commit is contained in:
Kenox 2022-11-03 18:59:03 +01:00
commit 2a0f809ca8
3 changed files with 3 additions and 4 deletions

View file

@ -176,6 +176,7 @@ haste.prototype.addLineNumbers = function(lineCount) {
div.classList.add('linenumber');
div.style.marginTop = i * 16 + 'px';
let line = i + 1;
div.id = 'line' + line;
div.href = '#' + line;
div.onclick = function() {
highlightLine(line);

File diff suppressed because one or more lines are too long

View file

@ -25,12 +25,10 @@
if(window.location.hash) {
const hash = window.location.hash.substring(1);
highlightLine(hash)
document.getElementsByClassName("highlight")[0].scrollIntoView({
document.getElementById("line" + hash)[0].scrollIntoView({
behavior: 'smooth',
block: 'center'
});
document.getElementById("box").scrollLeft = 0
}
};
// Set up the pop state to handle loads, skipping the first load