bitworking / react-gsap

React components for GSAP
https://bitworking.github.io/react-gsap/
Other
582 stars 34 forks source link

Accept alternative behaviors to "invalidate()" #6

Closed dominguesgm closed 4 years ago

dominguesgm commented 5 years ago

In the current implementation, when the to vars are changed, the TweenLite animation is invalidated. This, however, may cause undesired behavior when adjusting the to vars as a result of making the animation responsive.

For example, imagine you are using from: {x: 0, y: 0} and to: {x: 50, y: 25}. However, if you resize the screen (or with any other condition), you want to to be {x: 25, y: 50}, the current process of updating the to values will be equivalent of also updating from to the current position of the animation.

The following image should help understand the situation I'm describing.

gsap feature

What I am suggesting is a prop which will toggle between the default behavior and the behavior I'm trying to achieve.

I will be forking this repository and working on this change because it is something I need rather urgently. If, when it's finished, it looks like something worth merging into this package, I will gladly open a pull request.

bitworking commented 4 years ago

I've added this prop (which I probably rename in the next version) in the newest version: https://bitworking.github.io/react-gsap/src-components-tween#props