Repository navigation
Make smooth scrolling instant from before any hook - #136
Merged
Merged
Conversation
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>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #127
What changes
STILL_CSSsetsscroll-behavior:auto!importanton*,*::before,*::afterinstead of only onhtml.prepare()'s init script adopts that one rule before any page code runs, so it already applies during abeforehook.STILL_CSSitself is adopted only after the hook.behavior: "smooth"to"instant"inscroll,scrollToandscrollByonwindow, and in those plusscrollIntoViewonElement.prototype. The options object is copied, and numeric and boolean calls (scrollIntoView(true)) pass through as they are. The window patch sits onwindowitself, because a global's methods aren't onWindow.prototype.What it fixes, measured through the CLI with the left side smooth and the right side instant:
beforehook setsscrollTopon an inner scroller with CSSscroll-behavior: smooth(animates about 1s)beforeShotdoes the samebeforeShotcallswindow.scrollTo({behavior: "smooth"})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 changebeforeShotcallsel.scrollIntoView({behavior: "smooth"})ordocument.scrollingElement.scrollTo({behavior: "smooth"})Three guard-rail tests cover these cases (inner scroller, window,
scrollIntoView) on a newsmooth-scrollfixture. All three fail on main.Launch flags: measured, all skipped
Method:
mcr.microsoft.com/playwright:v1.62.0-nobleon arm64.--force-color-profile=srgb --font-render-hinting=none --disable-lcd-text --disable-skia-runtime-opts)variesand 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-textalone. 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).--disable-threaded-animation --disable-threaded-scrolling --disable-checker-imaging)--disable-background-timer-throttling --disable-renderer-backgrounding)--force-color-profile=srgb.The visual suite passes with all nine flags too (401 of 401 on macOS).
--deterministic-modewas 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