8000 Refactor FadeContent: GSAP migration, seconds units (AnimatedContent-like) and custom scroller support by freakdaniel · Pull Request #731 · DavidHDev/react-bits · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@freakdaniel
Copy link
Contributor
@freakdaniel freakdaniel commented Nov 24, 2025

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

  1. 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

  2. Safe Cleanup
    Implements st.kill() and gsap.killTweensOf(), ensuring no memory leaks or zombie animations when the component unmounts

  3. 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

  4. Exit Animations
    Introduced disappearAfter, disappearDuration, and disappearEase props. Elements can now fade out (and re-apply blur) automatically after the entry animation completes

  5. Technical
    Added visibility: hidden (or invisible class) to prevent the unstyled content from flashing before GSAP initializes

Testing

  1. Verify that animations work inside nested scroll containers
  2. Navigate away from the page and back to ensure no errors occur in the console (cleanup check)
  3. Test disappearAfter={2} to see the element fade out and blur again

@freakdaniel
Copy link
Contributor Author

Forgot to update landing in the previous commit :p

I'll update Fade Content too in a while

…ke) instead of 'easing' and update related documentation/landing; adjust minimum values for disappear duration and delay in demos
@freakdaniel
Copy link
Contributor Author

@DavidHDev done with this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0