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

overshootClamping not working as expected #225

Closed
stnwk opened this issue Sep 10, 2018 · 4 comments
Closed

overshootClamping not working as expected #225

stnwk opened this issue Sep 10, 2018 · 4 comments

Comments

@stnwk
Copy link

stnwk commented Sep 10, 2018

Hi :)

Thanks for this awesome lib!

I believe I have found an issue with the overshootClamping option.
I have isolated the problem in this codesandbox https://codesandbox.io/s/91k1vxp7r4 (take a look at the console output).

What's the issue?

I want to animate a value imperatively going from 0 to 1000. I want it to animate smoothly, but never bounce. I thought this was achievable by using overshootClamping.

overshootClamping, controls if the spring should be clamped and not bounce

See https://github.com/drcmda/react-spring/blob/master/API.md#spring-configs

However, as you can see in the codesandbox console output the value does exceed it's animation goal of 1000. I was not expecting this to happen.

image

Is this a bug? If not, what exactly is the purpose of overshootClamping and how would I achieve my goal?

Btw: When overshootClamping is set to false (default) the value exceeds/overshoots the limit multiple times - so I guess it's working almost correctly except for the last animation frame?

I am using react-spring 5.7.1

Cheers,
Stefan

@stnwk
Copy link
Author

stnwk commented Sep 10, 2018

I belive the fix is to change < and > here to <= and >=:

https://github.com/drcmda/react-spring/blob/8ad944296967a8c5b27a889d036adcc0625af04d/src/addons/OscillatorAnimation.js#L143

I don't think the goal should be to stop the animation after the value overshoots the animation goal once, but as soon as it overshoots?

What do you think?

@drcmda
Copy link
Member

drcmda commented Sep 10, 2018

@stnwk do you use oscillatoranimation or the default spring impl? In the default it updates the value before checking for overshoot, i've moved it a little bit down and now it works, will have to release, though.

@stnwk
Copy link
Author

stnwk commented Sep 10, 2018

Oh shoot, good point - no I'm using the default spring implementation. What does it mean for me now?

@drcmda
Copy link
Member

drcmda commented Sep 10, 2018

Should be fixed in 5.7.2

@drcmda drcmda closed this as completed in d1ec68f Sep 10, 2018
szjemljanoj pushed a commit to szjemljanoj/react-spring that referenced this issue Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants