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

Popmotion: bounce animation with some durations / velocity updates to NaN #910

Open
jedierikb opened this issue May 2, 2021 · 2 comments

Comments

@jedierikb
Copy link

When starting a bounce animation with some configurations of duration and velocity can result in NaN update values.
(The animations do successfully end at their to values though.)

For example:
https://codesandbox.io/s/popmotion-velocity-nan-et3t3?file=/src/index.tsx:0-425

import { animate } from "popmotion";

const $root = document.getElementById('root');

const from = 1;
const to = 5;
const duration = 4000;
const type = 'spring';
const bounce = 0.5;
const velocity = 0.9988001159034534;

animate({
  from: from,
  to: to,
  duration: duration,
  type: type,
  bounce: bounce,
  velocity: velocity,
  onUpdate: latest => $root.innerHTML = 
  `from: ${from}<br>to ${to}<br>latest: ${latest}`
})

This animation should not have NaN values onUpdate

It seems that the actual Nan is created hereabouts:


as a result of an invalid dampingRatio.

Please let me know how I could help with this issue. Thank you.
This issue was initially discovered here
motiondivision/motion#1094

@jedierikb
Copy link
Author

Seems to happen when dampingRatio becomes NaN as a result of 0/0 here:

const dampingRatio = damping / (2 * Math.sqrt(stiffness * mass))

Where the damping is 0 and the stiffness is 0.

And it seems 0 values can come from approximateRoot

@jedierikb
Copy link
Author

Can I help clarify this issue or help to patch?

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

1 participant