useSpring, transforms, CSS positioning, changing midflight, and preserving momentum #1820
-
I'm trying to do something kind of complicated with react-spring on the web. In React, I have a component where the start and end positions are determined in CSS. So I run The idea is that I get the "from" bounding rect before the animation starts, get the "to" bounding rect in This works! But I want to go even further and have the spring respond dynamically when the target changes. So I wrote some more routines to figure out when the spring is interrupted, get the current transformation out of the This also works! So now I have a component which is positioned via CSS and can transition between states with a spring animation. But now the problem is, when the animation gets interrupted and I recalculate the Is there a way to make an animation in |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Do you have an example you could share? I'm struggling to imagine what you're trying to do here. |
Beta Was this translation helpful? Give feedback.
-
So, I just found out about view interpolation and it simplified things a lot for me. Now I can take raw, absolute x/y/w/h and animate between them. Example here. https://codesandbox.io/s/rkkes I don't have the first run bug quite fixed yet, but I'm almost there. |
Beta Was this translation helpful? Give feedback.
So, I just found out about view interpolation and it simplified things a lot for me. Now I can take raw, absolute x/y/w/h and animate between them.
Example here. https://codesandbox.io/s/rkkes I don't have the first run bug quite fixed yet, but I'm almost there.