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

[BUG] motionValue sometimes set to NaN via animate utility #1094

Closed
jedierikb opened this issue Apr 10, 2021 · 5 comments
Closed

[BUG] motionValue sometimes set to NaN via animate utility #1094

jedierikb opened this issue Apr 10, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@jedierikb
Copy link

Sometimes when resetting an animate on a motionValue, the motionValue becomes NaN.

In this codepen, click to reset the target of the animation a few times and the motion value becomes set to NaN.
https://codesandbox.io/s/animate-results-in-nan-um7ec?file=/src/App.tsx

The motion value should never be set to NaN.

@jedierikb jedierikb added the bug Something isn't working label Apr 10, 2021
@jedierikb
Copy link
Author

Here is a video
https://photos.app.goo.gl/NYTusgmh347JnXik8

@jedierikb
Copy link
Author

NaN happens when the animate object has the duration parameter and does not seem to happen when duration is omitted.

https://codesandbox.io/s/animate-results-in-nan-forked-0xlq6?file=/src/App.tsx:405-426

@jedierikb
Copy link
Author

Poking about in framer-motion source, I see my calls go to popmotion via

but grabbing some parameters which cause the bug and feeding them into popmotion directly does not cause onUpdate to go NaN:
https://codesandbox.io/s/animate-results-in-nan-forked-nopfx?file=/src/App.tsx

Not sure off the top of my head the next best path to debug this...

@jedierikb
Copy link
Author

Dug into popmotion a bit to trace this.

It seems that sometimes when a derived Velocity is added to a settings object, tween updates return NaN.

Here is a contrived example with a known errant velocity and duration:
https://codesandbox.io/s/animate-results-in-nan-um7ec?file=/src/App.tsx

Here are my rough notes from tracing in popMotion:

in createSpring, if damping == 0 and stiffness == 0, then
dampingRatio is NaN
and then dampedAngularFreq_1 is NaN
and then ResolveSpring returns NaN

Let me know if I should open a ticket in popmotion. Thank you for help in debuggng this.

@mattgperry
Copy link
Collaborator

Thanks for the popmotion ticket! I'll close this one so it's just tracked in one place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants