Skip to content

Preserve fractional scroll offset for pixel-smooth trackpad scrolling - #6039

Open
hmrserver wants to merge 2 commits into
xtermjs:masterfrom
hmrserver:smooth-scroll
Open

Preserve fractional scroll offset for pixel-smooth trackpad scrolling#6039
hmrserver wants to merge 2 commits into
xtermjs:masterfrom
hmrserver:smooth-scroll

Conversation

@hmrserver

@hmrserver hmrserver commented Jul 5, 2026

Copy link
Copy Markdown

This preserves the fractional viewport offset so trackpad scrolling can move at pixel granularity while rows remain the unit of layout and rendering.

Changes:

  • Keep the row calculation intact, then store the leftover pixel offset as _pixelOffset = newRow * cellHeight - scrollTop.
  • Apply that offset as a devicePixelRatio-rounded translateY() on the screen element.
  • Add will-change: transform so the in-between motion stays on the compositor.
  • Reset the offset when switching between the normal and alt buffers.
  • Replace the WebGL addon's one-shot beginFrame() boolean with a monotonic clearModelGeneration counter. With a shared atlas, the boolean can be consumed by the first renderer that sees it; the counter lets each renderer observe and handle model clears independently.

Unaffected behavior:

  • Selection still uses the same row model.
  • Alt-buffer apps still reset to an aligned viewport.
  • smoothScrollDuration is unchanged; this only affects the fractional offset inside each row step.

Demo recording:
BEFORE:

laggy.scroll.mp4

AFTER:

smooth.scroll.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant