feat(ScrollArea): add fade prop for fading scrollable sides, migrate Table fade to scroll-driven animations#648
Merged
Conversation
Uses CSS scroll-driven animations to display the fade mask without any JS: scroll timelines animate registered custom properties used as mask gradient stops, so the fade only appears on the sides that can be scrolled towards. The mask is applied to the scrollable element only, keeping the custom scrollbars unmasked. Browsers without support render the scroll area without the mask. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VTo6CXkUBtLeftQaZ9RU4X
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VTo6CXkUBtLeftQaZ9RU4X
size-limit report 📦
|
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VTo6CXkUBtLeftQaZ9RU4X
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VTo6CXkUBtLeftQaZ9RU4X
Replaces the useFadeSide scroll tracking with the same CSS-only approach used by the ScrollArea fade prop, removing the scroll and resize listeners along with the JS RTL handling. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VTo6CXkUBtLeftQaZ9RU4X
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
Adds a new
fadeboolean prop toScrollAreathat displays a fade mask on the sides of the area that can be scrolled towards, and migrates the existingTablescroll fade to the same technique.The implementation is CSS-only, built on scroll-driven animations instead of the JS-toggled class approach used by the older fade implementations:
@propertycustom properties (--rs-scroll-area-fade-{block,inline}-{start,end},--rs-table-fade-{start,end}) drive the stop positions ofmask-imagelinear gradients (ScrollArea combines the two axes withmask-composite: intersect). The alpha falloff is eased (smoothstep approximated with intermediate stops at fractions of the fade size) rather than a linear ramp.animation-timeline: scroll(self block/inline)and ananimation-rangecovering the first/last fade-size distance of the scroll range, so a fade appears only on the sides with remaining scrollable content and reacts to scrolling without any JS.[dir="rtl"].@supports (animation-timeline: ...): browsers without scroll-driven animations support (e.g. current stable Firefox) render without the fade.Table migration:
Tableno longer uses theuseFadeSidehook — its scroll/resize listeners, React state updates and JS RTLscrollLefthandling are removed, along with the--fade-start/--fade-endclasses and the@propertytransition. The fade now also grows proportionally with the scroll position and uses the same eased gradient as ScrollArea.useFadeSideitself is kept sinceTabsstill uses it for its scroll control buttons. Note this changes Table's fade behavior in stable Firefox (no fade until it ships scroll-driven animations), where the previous JS implementation rendered one.Also adds a
fadeStorybook story and changesets (minor for the ScrollArea prop, patch for the Table refactor).Related Issue
N/A
Screenshots / Recordings
Verified in Chromium via Storybook, for both ScrollArea and Table:
Notes for Reviewers
--rs-scroll-area-fade-size/--rs-table-fade-size(set on the root elements; Table keeps its previous--rs-unit-x4, ScrollArea uses--rs-unit-x6).@propertyinitial values keep the fades at0, so even where the mask applies but animations somehow don't run, the mask resolves to fully opaque (no visual change).🤖 Generated with Claude Code
https://claude.ai/code/session_01VTo6CXkUBtLeftQaZ9RU4X