editor: keep the scroll steady with the pin alone

This commit is contained in:
Ammar Ahmed
2026-08-27 14:16:43 +05:00
parent 0236b9e4fe
commit 4daeb33fa2

View File

@@ -278,7 +278,10 @@ export function viewportPlugin(heights: HeightMap): Plugin<ViewportState> {
const resolved = findScrollParent(editorView.dom);
if (!resolved || resolved === scrollParent) return;
scrollParent?.removeEventListener("scroll", schedule);
resolved.style.overflowAnchor = "auto";
// The browser's own scroll anchoring compensates for the same height
// changes the pin does, and the two corrections add up to twice the
// shift. The pin is the one that knows which page to hold on to.
resolved.style.overflowAnchor = "none";
resolved.addEventListener("scroll", schedule, { passive: true });
scrollParent = resolved;
};