Roman Kopo Posted May 3 Posted May 3 Hi, I'm working with React and think of something like <AnimatePresence/> which is available in (Framer) Motion. The goal is to remove or add an element from the DOM with an animation. What's the recommended way to achieve this? Is there something available like the AnimatePresence component in Framer?
Solution Rodrigo Posted May 3 Solution Posted May 3 Hi @Roman Kopo and welcome to the GSAP Forums! At the moment there isn't something like that, the approach I could suggest is a conditional rendering using the onComplete when removing an element. When adding an element you can use add the element with an opacity: 0 and then apply the other transforms you want/need. Another option could be to borrow some logic from this demo: See the Pen MWmqzjE by GreenSock (@GreenSock) on CodePen. Hopefully this helps Happy Tweening! 1
Roman Kopo Posted May 5 Author Posted May 5 thanks @Rodrigo for your suggestion of the preferred implementation and the example!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now