pmndrs / react-spring

✌️ A spring physics based React animation library
http://www.react-spring.dev/
MIT License
28k stars 1.19k forks source link

Snap effect when transitioning out of a component. #585

Closed nateshmbhat closed 5 years ago

nateshmbhat commented 5 years ago

I am trying to have an animation every time the picture component gets changed. The first animation when the page loads , is fine. When I click the '+' button , the animation kind of snaps back to its final position in a jerk and is not smooth. I don't understand why this snap effect is happening. How do i fix this ?

https://codesandbox.io/s/wn6jp23vxl

drcmda commented 5 years ago

it's easier to think of spring as a value interpolator, it doesn't do magic. if you want two elements on top of one another in css you need to position them absolutely. you can do this in plain css classes (.MainSlide in your case) or even in the spring definition, for instance from: { position: 'absolute', .... in other situations you want items to be stacked, like in a list. but everything's under your full control.