Refactor FadeContent: GSAP migration, seconds units (AnimatedContent-like) and custom scroller support #731
+517
−134
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.
I have modified FadeContent to match the architecture and reliability of the main animation component (AnimatedContent). This PR contains changes for all 4 component variants (JS + CSS/JS + TW, TS + CSS/TS + TW)
So, again, KEY CHANGES
Architecture
Before: Used IntersectionObserver mixed with CSS Transitions and setTimeout. duration was in milliseconds
After: Refactored to use GSAP Timeline + ScrollTrigger. Duration and delay are now in seconds (e.g., 1 instead of 1000) to match GSAP standards and AnimatedContent
Safe Cleanup
Implements st.kill() and gsap.killTweensOf(), ensuring no memory leaks or zombie animations when the component unmounts
Custom Scroller Support
Added logic to detect specific scroll containers (via container prop or #snap-main-container id)
Essential for layouts using overflow: scroll, CSS Scroll Snap, or third-party scroll libraries where the window is not the scroller
Exit Animations
Introduced disappearAfter, disappearDuration, and disappearEase props. Elements can now fade out (and re-apply blur) automatically after the entry animation completes
Technical
Added visibility: hidden (or invisible class) to prevent the unstyled content from flashing before GSAP initializes
Testing