fix(gallery): eliminate marquee ping-pong by direction-aware, phase-continuous wrap - #28
Open
Faych (neverbiasu) wants to merge 1 commit into
Open
Conversation
…ontinuous wrap - wrap only on the edge each row travels toward; checking both edges made every wrap land on the other edge's trigger, causing per-frame ping-pong - shift by exactly one period instead of clamping, so the phase stays continuous and no residual offset accumulates - measure the loop period from tile offsetLeft rather than scrollWidth/2, which included the track's horizontal padding - drop scroll-behavior:smooth from .wall/.carousel; CSS smoothing fought the per-frame scrollLeft writes (arrow buttons pass behavior explicitly) - remove the now-unnecessary isResetting lock and dead-zone guard
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
The auto-scrolling poster walls (reel-page) and card carousels (idea-page) jittered violently — rows visibly shook left/right every frame instead of drifting smoothly. DevTools showed
scrollLeftping-ponging between0and51528on consecutive frames.There were two independent root causes, both fixed here.
Root cause 1 — the wrap checked both edges
A row travelling right starts at
scrollLeft = 0, so it immediately satisfies the lower bound, jumps to the upper bound, which immediately satisfies the upper bound, and jumps back. Ping-pong, every frame.Fix: each row only checks the edge it is actually travelling toward (
dir-aware), and shifts by exactly one period instead of clamping — clamping parks the value right on the other trigger line and leaves a residual offset that accumulates into a visible jump.Root cause 2 — CSS
scroll-behavior: smoothon the track.wall/.carouselboth hadscroll-behavior: smooth, so every per-framescrollLeftwrite started a competing CSS scroll animation. Removed from both stylesheets; the arrow buttons passbehavior: "smooth"explicitly toscrollBy(), so their UX is unchanged.Also fixed
scrollWidth / 2, which includes the track'spadding: 44px 32px(~48px error) — every wrap jumped by that delta. Now measured from the DOM:kids[n].offsetLeft - kids[0].offsetLeft.isResettinglock and the dead-zone guard added in the earlier attempt: they were patches on a wrong model, and the lock swallowed frames.Files changed
DEADZONEreferencescroll-behavior:smoothfrom.wallscroll-behavior:smoothfrom.carouselNet: +30 / −11, no new dependencies, no behavior change to lightbox / filters / arrows.
Todo
reel-pagemarqueeidea-pagecarouseloffsetLeftinstead ofscrollWidth/2scroll-behavior:smoothfrom.walland.carouselisResettinglock and dead-zone guardDEADZONE/isResetting/ debug logs (grepclean)How to test