Fix scrolling behaivour

This commit is contained in:
Kenox 2022-11-04 09:42:11 +01:00
commit 05a53192e2
2 changed files with 5 additions and 6 deletions

View file

@ -178,12 +178,11 @@ haste.prototype.addLineNumbers = function(lineCount) {
if(window.location.hash) { if(window.location.hash) {
const hash = window.location.hash.substring(1); const hash = window.location.hash.substring(1);
highlightNew(getLineElement(hash)); const lineElement = getLineElement(hash)
highlightNew(lineElement);
getLineElement(hash).scrollIntoView({ const y = lineElement.getBoundingClientRect().top + window.pageYOffset;
behavior: 'smooth', window.scrollTo({top: y, behavior: 'smooth'});
block: 'center'
});
} }
/*for (var i = 0; i < lineCount; i++) { /*for (var i = 0; i < lineCount; i++) {
let div = document.createElement('a'); let div = document.createElement('a');

File diff suppressed because one or more lines are too long