mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
Fix markdown scrolling between elements being too jumpy (#166746)
Fixes #165055 We need to consider the distance between the end of the previous element and start of the next element. Previously we were taking distance from start of the previous to start of the next
This commit is contained in:
@@ -133,8 +133,9 @@ export function scrollToRevealSourceLine(line: number, documentVersion: number,
|
||||
if (next && next.line !== previous.line) {
|
||||
// Between two elements. Go to percentage offset between them.
|
||||
const betweenProgress = (line - previous.line) / (next.line - previous.line);
|
||||
const elementOffset = next.element.getBoundingClientRect().top - previousTop;
|
||||
scrollTo = previousTop + betweenProgress * elementOffset;
|
||||
const previousEnd = previousTop + rect.height;
|
||||
const betweenHeight = next.element.getBoundingClientRect().top - previousEnd;
|
||||
scrollTo = previousEnd + betweenProgress * betweenHeight;
|
||||
} else {
|
||||
const progressInElement = line - Math.floor(line);
|
||||
scrollTo = previousTop + (rect.height * progressInElement);
|
||||
|
||||
Reference in New Issue
Block a user