diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/FrameBasedAnimationDriver.java b/ReactAndroid/src/main/java/com/facebook/react/animated/FrameBasedAnimationDriver.java index f697e98f885..86eac84521b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/animated/FrameBasedAnimationDriver.java +++ b/ReactAndroid/src/main/java/com/facebook/react/animated/FrameBasedAnimationDriver.java @@ -19,6 +19,9 @@ import com.facebook.react.bridge.ReadableMap; */ class FrameBasedAnimationDriver extends AnimationDriver { + // 60FPS + private static final double FRAME_TIME_MILLIS = 1000d / 60d; + private long mStartFrameTimeNanos = -1; private final double[] mFrames; private final double mToValue; @@ -40,10 +43,8 @@ class FrameBasedAnimationDriver extends AnimationDriver { mStartFrameTimeNanos = frameTimeNanos; mFromValue = mAnimatedValue.mValue; } - long timeFromStartNanos = (frameTimeNanos - mStartFrameTimeNanos); - // frames are calculated at 60FPS, to get index by a given time offset from the start of the - // animation, we take the time diff in millisecond and divide it by 60 frames per 1000ms. - int frameIndex = (int) (timeFromStartNanos / 1000000L * 60L / 1000L); + long timeFromStartMillis = (frameTimeNanos - mStartFrameTimeNanos) / 1000000; + int frameIndex = (int) (timeFromStartMillis / FRAME_TIME_MILLIS); if (frameIndex < 0) { throw new IllegalStateException("Calculated frame index should never be lower than 0"); } else if (mHasFinished) {