fix(gallery): subpixel scroll stall + scroll resync + resize remeasure - #34
Open
Faych (neverbiasu) wants to merge 1 commit into
Open
fix(gallery): subpixel scroll stall + scroll resync + resize remeasure#34Faych (neverbiasu) wants to merge 1 commit into
Faych (neverbiasu) wants to merge 1 commit into
Conversation
Chrome rounds subpixel scrollLeft writes to the nearest integer, so writing 0.4/0.45px directly rounds to 0 every frame and the marquee stalls. Keep the fractional position in a floating-point phase accumulator and only write the integer part to scrollLeft. - phase accumulator: s.phase += SPEED * dir; write Math.round(s.phase) - manual-scroll resync: scroll listener compares against the last written value and resyncs the phase on user scrolls (arrows, touch, wheel) - resize remeasurement: setup is idempotent (dataset.looping guard), re-measures the loop period and re-syncs phase to the current position without duplicating content a second time - retain main's updated 32px padding (no CSS changes) - fix stale-state capture: listeners looked up state by closure, which broke hover-pause after resize re-ran setup; now look up by element
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.
Summary
Fix the marquee stall caused by Chrome subpixel
scrollLeftrounding in the gallery carousels.This patch keeps the auto-scroll phase continuous while still allowing user-driven manual scrolls to resync cleanly after pointer/touch/wheel interaction. It also re-measures loop periods on resize without duplicating content again.
Root cause
Chrome rounds subpixel
scrollLeftvalues to integers during DOM writes. When the marquee loop keeps updating from a stale phase, the next frame can effectively write0.4pxor0.45px, which Chrome rounds to0, causing the carousel to appear stuck.What changed
docs/idea-page/gallery.js_lastWrittenvalue for the last DOM writesingleWidthon resize without duplicating content againdocs/reel-page/gallery.jsscrollLeftvalueFiles changed
docs/idea-page/gallery.jsdocs/reel-page/gallery.jsVerification
upstream/mainNotes
This is a follow-up to the earlier marquee ping-pong fix that was already merged upstream. This PR specifically addresses the remaining subpixel/rounding stall issue.