Fix Animated spring jest test

Reviewed By: TheSavior

Differential Revision: D5786252

fbshipit-source-id: 9f97b36bd2d6faebc95f2f78889fb382a3544479
This commit is contained in:
Spencer Ahrens 2017-09-08 16:26:48 -07:00 committed by Facebook Github Bot
parent c88b2b2c65
commit 1afc93d18a
1 changed files with 4 additions and 1 deletions

View File

@ -196,7 +196,10 @@ class SpringAnimation extends Animation {
// The following post provides a lot of thoughts into how to build this
// loop: http://gafferongames.com/game-physics/fix-your-timestep/
const TIMESTEP_MSEC = 1;
const numSteps = Math.floor((now - this._lastTime) / TIMESTEP_MSEC);
const numSteps = Math.max(
1, // Always take at least one step to make progress.
Math.floor((now - this._lastTime) / TIMESTEP_MSEC),
);
for (let i = 0; i < numSteps; ++i) {
// Velocity is based on seconds instead of milliseconds