Jump to content
Search Community

React - Tween Y pos of items in a list and refresh position

flefloch test
Moderator Tag

Recommended Posts

Hello,

 

I've been using a lot GSAP back in time when I was working on Flash animations and I'm more than happy to see that this great lib is still alive 👍

 

I'm working on a React webApp and when needing to add some tweening on it my first thought was obviously for GSAP.

 

Here is my problem I have a list of items. When the user click on one item it should disappear (simple tween on opacity) and then all the items above need to tween up to fill the space left by the disappeared item.

After animation is done I'm removing the item from my state, but my problem is that all the divs keep the transformation applied before when what I want is to start a new "fresh" list so user can click once again and launch the same animations.

I'm wondering if my probelm couldn't be that i'm doing it the wrong way and messing with the refs but I can't see how to do it other way.

Any help is appreciated.

Thanks

 

See the Pen QWypRgZ by fleflochn (@fleflochn) on CodePen

Link to comment
Share on other sites

Hum, that seems to be the right thing to do (thanks for pointing this out), but I'm still having a problem with my items not being "refreshed" properly.

I think I have some mismatch from my side the way I'm handling the refs but I can't figure out what is the issue... 🤔

Link to comment
Share on other sites

Thank for this demo.

I'll have to change few things since my list is actually coming from the props (updated by Redux store) so I need to clean the itemsRef array when props are changed  but I think I get the point : use Timeline instead of multiple tweens created seperately and sending params onComplete.

Just one question, you're using gsap instead of directly TweenLite, is this for performance issue or is it just a habit?

 

Thanks for your help 👍

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...