fix(markdown): keep the preview painted while scrolling (#6908)

Trackpad scrolling in the Markdown preview could leave a large part of it blank until the next scroll. The preview moves itself on each wheel event with scrollBy, and in WebKit a run of scrollBy calls can leave the compositor at an older, never-painted offset than the page's. Setting scrollTop/scrollLeft keeps them in step; the source editor's large wheel jumps and the diff divider's wheel did the same and now set offsets too.

A fenced code block overflowing by a pixel no longer counts as a vertical scroller, and a nested scroller keeps the wheel only while it can still move in that direction, so scrolling no longer stops over code blocks.
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-30 10:31:45 +08:00
1 джерело 4ca46032c4
коміт e9f3aef5ae
6 files changed
+103 -35

No files matched your search

+5 -2
Переглянути файл
@@ -503,7 +503,10 @@ export class UnalignedPanes implements DiffPanes {
this.interruptScroll();
this.leadWheel("b");
this.passOn("b", e);
mv.b.scrollDOM.scrollBy(e.deltaX, e.deltaY);
// Offsets rather than scrollBy, which can leave WebKit's compositor at a stale, unpainted offset.
const scroller = mv.b.scrollDOM;
scroller.scrollLeft += e.deltaX;
scroller.scrollTop += e.deltaY;
};
this.divider.addEventListener("wheel", onWheel, { passive: false });
this.cleanup.push(() => this.divider.removeEventListener("wheel", onWheel));
@@ -616,7 +619,7 @@ export class UnalignedPanes implements DiffPanes {
const room = dy > 0 ? el.scrollHeight - el.clientHeight - el.scrollTop : el.scrollTop;
const scroll = (by: number, dir: number) => {
const before = other.scrollTop;
other.scrollBy(0, by);
other.scrollTop += by;
if (other.scrollTop !== before) this.passed[to] = { top: other.scrollTop, dir };
};
const passed = this.passed[to];