Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating duration in useSpring config part way through animation causes object to move "backward" #1163

Closed
tbntdima opened this issue Sep 29, 2020 · 18 comments · Fixed by #1378
Assignees
Labels
kind: bug Something isn't working
Milestone

Comments

@tbntdima
Copy link

tbntdima commented Sep 29, 2020

When I update the duration via useState, animation flickers back, not to initial value though.

I think you will understand from codesandbox example. Try to click the button, once the animation is 50% done.

codesandbox example

@aleclarson aleclarson added kind: bug Something isn't working v9 and removed question labels Sep 29, 2020
@aleclarson aleclarson added this to the v9.0.0-rc.4 milestone Sep 29, 2020
@aleclarson

This comment has been minimized.

@tbntdima

This comment has been minimized.

@aleclarson

This comment has been minimized.

@tbntdima

This comment has been minimized.

@aleclarson

This comment has been minimized.

@tbntdima

This comment has been minimized.

@tbntdima

This comment has been minimized.

@aleclarson

This comment has been minimized.

@tbntdima

This comment has been minimized.

@joshuaellis joshuaellis modified the milestones: v9.0.0-rc.4, v9.1.0 Mar 18, 2021
@joshuaellis joshuaellis self-assigned this Mar 28, 2021
@joshuaellis
Copy link
Member

@tbntdima what are you expecting to happen here?

I've forked the example so I can see the two runners side by side (one has its duration changed): https://codesandbox.io/s/modern-bush-cubzn?file=/src/App.js

As I can see spring doesn't reset to the default transform value, the distance is probably a percentage of time spent so it moves back a little bit to make the distances the same for the percentage of time already passed.

Are you expecting the object to stay in the same position and slow down because that would be almost like it has an easing function (in this case ease-out).

Or are you expecting the entire spring to reset? If so, do you think that makes sense to do so? 🤔

@tbntdima
Copy link
Author

@joshuaellis I guess the issue was fixed already (haven't tested yet).
Before when I was changing duration, I was expecting animation to either slow down or speed up from the current position, but instead, animation was starting over from the beginning.

@joshuaellis
Copy link
Member

Okay, it'd be great if you could check out the link I posted above to see if that's whats expected and we could talk further.

@tbntdima
Copy link
Author

@joshuaellis just checked the link. It seems that the issue is still there. When I click on the button, the first box flickers back a bit, instead of slowing down.

@joshuaellis
Copy link
Member

Okay, so let's say that the box moves over 2000secs, at 1000secs (50%) you change the total duration to 4000 secs makes its current place, 1000seconds to be 25% complete.

What you're expecting the box to stay where it is in terms of percentage of competition (in this case 50%) and take double the time to finish the last 50% in double the time?

@tbntdima
Copy link
Author

@joshuaellis yep, sounds right for me. Not sure if its intuitive for other people, but thats what I would expect on duration change. wdyt?

@joshuaellis
Copy link
Member

I think it would make for a more pleasing animation (no moving backwards) and probably makes more sense in terms of physics.....

@creativiii, @CodyJasonBennett what do you think?

@leo-petrucci
Copy link

That's how I'd expect that to work!

@joshuaellis joshuaellis changed the title Update duration in config not working properly Updating duration in useSpring config part way through animation causes object to move "backward" Mar 28, 2021
@tbntdima
Copy link
Author

tbntdima commented Apr 8, 2021

Thanks @joshuaellis 🙂

cameron-martin pushed a commit to cameron-martin/react-spring that referenced this issue May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants