Skip to content

Make smooth scrolling instant from before any hook - #136

Merged
tmashara merged 2 commits into
mainfrom
claude/issue-127
Nov 3, 2026
Merged

tmashara merged 2 commits into
mainfrom
claude/issue-127

Conversation

@tmashara

@tmashara tmashara commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Closes #127

What changes

  • STILL_CSS sets scroll-behavior:auto!important on *,*::before,*::after instead of only on html.
  • prepare()'s init script adopts that one rule before any page code runs, so it already applies during a before hook. STILL_CSS itself is adopted only after the hook.
  • The same init script rewrites behavior: "smooth" to "instant" in scroll, scrollTo and scrollBy on window, and in those plus scrollIntoView on Element.prototype. The options object is copied, and numeric and boolean calls (scrollIntoView(true)) pass through as they are. The window patch sits on window itself, because a global's methods aren't on Window.prototype.

What it fixes, measured through the CLI with the left side smooth and the right side instant:

Case main this PR
before hook sets scrollTop on an inner scroller with CSS scroll-behavior: smooth (animates about 1s) 99.65%, about 127k px unstable clean
beforeShot does the same 99.30%, with unstable px clean
beforeShot calls window.scrollTo({behavior: "smooth"}) renderdiff's scrollTo(0,0) lands mid-animation and leaves scrollY stuck at 21 to 43px. The result is a stable false diff of about 98% that reads as a real change clean
beforeShot calls el.scrollIntoView({behavior: "smooth"}) or document.scrollingElement.scrollTo({behavior: "smooth"}) Animates the viewport the same way (scrollY 8 to 21px after 50ms) clean

Three guard-rail tests cover these cases (inner scroller, window, scrollIntoView) on a new smooth-scroll fixture. All three fail on main.

Launch flags: measured, all skipped

Method:

  • Base vs base over 52 fixture routes at @375 and @1280 (104 shots), 2 to 3 runs per flag set.
  • macOS, and Linux in mcr.microsoft.com/playwright:v1.62.0-noble on arm64.
  • One real site (playwright.dev: 3 routes, 2 widths, 3 runs).
Group Effect Decision
Rasterisation (--force-color-profile=srgb --font-render-hinting=none --disable-lcd-text --disable-skia-runtime-opts) Unstable px, varies and retries are the same in every run: 283,360 px, 203,360 px and 2 to 3, all from the deliberately unstable fixtures. On macOS no pixels change. On Linux every text pixel changes (99 of 99 shots), caused by --disable-lcd-text alone. The macOS–Linux gap narrows from 5.12M to 4.64M px, but 0 shots become hash-identical, even with the same webfont on both OSes (5,919 → 3,951 px). Skip. Accepted hashes stay OS-specific anyway, and the flags would invalidate every Linux accepted entry once for no gain in stability.
Threading (--disable-threaded-animation --disable-threaded-scrolling --disable-checker-imaging) No change in stability or in fixture pixels. Smooth-scroll timing is unchanged too. Skip
Background (--disable-background-timer-throttling --disable-renderer-backgrounding) Playwright already passes both, along with --force-color-profile=srgb. Skip (no-op)

The visual suite passes with all nine flags too (401 of 401 on macOS). --deterministic-mode was not tried.

For users

No pixel change, except on pages that used to be shot mid-scroll (smooth inner scrollers, or smooth window and element scrolls from hooks or page script). Those shots now match how the page looks once the scroll has settled. If you had accepted such a difference, re-accept it on the platform that checks, which for CI means in CI.

🤖 Generated with Claude Code

tmashara and others added 2 commits November 3, 2026 20:03
STILL_CSS puts scroll-behavior:auto on every element, not only html. The
init script adopts that one rule before page code runs, so a scroll a
before hook starts is instant too, and rewrites behavior:"smooth" to
"instant" in window.scroll/scrollTo/scrollBy.

Launch flags are unchanged: measured, none moved unstable px, varies or
retries on macOS or Linux.

Closes #127

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scrollIntoView and element scroll/scrollTo/scrollBy with behavior:"smooth"
animate as well, and those on the root move the viewport, so patch
Element.prototype with the same wrapper as window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmashara
tmashara merged commit e9f68bd into main Nov 3, 2026
3 checks passed
@tmashara
tmashara deleted the claude/issue-127 branch November 3, 2026 19:24
@tmashara tmashara mentioned this pull request Nov 4, 2026
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.

Pin Chromium rendering flags and instant scrolling so repeat loads paint the same pixels

1 participant