fix(interactions): measure by hand when the scroll timeline's scroller cannot scroll - #134
Merged
Merged
Conversation
…r cannot scroll A view timeline binds to the nearest ancestor that is a scroll container, and any non-visible overflow makes an element one whether or not it ever scrolls. With `overflow-x: hidden` on `html, body`, `body` becomes the timeline's scroller while the viewport is what moves, so the timeline stays active at one position and the scrub stands still. The scrub now trusts the timeline only when its scroller is the document's own or can scroll along the chosen axis, decided once per visibility entry; otherwise it measures the root against the viewport by hand, which is the arithmetic the timeline would have produced. The test stub gains a `source` so both paths are pinned.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
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.
What
lottieScrollScrubdrives the playhead from aViewTimelineon the animation's root. A view timeline binds to the nearest ancestor that is a scroll container, and any non-visible overflow makes an element one whether or not it ever scrolls. Withoverflow-x: hiddenonhtml, body(a common rule, and create-next-app's default stylesheet),bodybecomes the timeline's scroller while the viewport is what moves: the timeline stays active at one position and a page scrub stands still, with no warning.The scrub now trusts the timeline only when its scroller is the document's own (
document.scrollingElement) or can scroll along the chosen axis, decided once per visibility entry so the platform path stays free of layout reads; otherwise it measures the root against the viewport by hand, the same arithmetic the timeline would have produced. A scrollingdivis unaffected.Verified
main): a non-scrolling scroller falls back to geometry with no warning; a real scroller keeps the timeline; the check reruns on each entry; the inline axis checks inline extents. TheViewTimelinetest stub gainssourceandsetSource.pnpm checkgreen: 478 tests, coverage 100 / 97.43 / 100 / 100, budgets under, 34 pages rendered.html, body { overflow-x: hidden }: a page scrub that sat at one frame on 3.0.0 now runs 0 → 180 linearly across the root's journey, on both the component path (tall<Lottie>root, sticky<LottieDisplay>) and the hook path (setRootRefon a section). Without the rule, behaviour is identical to before.