Take progress within element into account for markdown scroll sync

Fixes #65504
This commit is contained in:
Matt Bierner 2019-01-02 14:35:51 -08:00
parent 88bc3b3d35
commit cba84fba5e
2 changed files with 5 additions and 3 deletions

File diff suppressed because one or more lines are too long

View file

@ -110,7 +110,8 @@ export function scrollToRevealSourceLine(line: number) {
const elementOffset = next.element.getBoundingClientRect().top - previousTop;
scrollTo = previousTop + betweenProgress * elementOffset;
} else {
scrollTo = previousTop;
const progressInElement = line - Math.floor(line);
scrollTo = previousTop + (rect.height * progressInElement);
}
window.scroll(window.scrollX, Math.max(1, window.scrollY + scrollTo));
}