ameyms / react-animated-number

React component for animating numbers
MIT License
168 stars 28 forks source link

Sometimes last frame is missed on mobile #15

Open NeXTs opened 7 years ago

NeXTs commented 7 years ago

Let's say we need to animate value from 0 to 2.5 during 600ms. Sometimes on iphone 5se (Chrome) last frame is missed, so value stops on 2.46 (for example) instead of 2.5. Layout will be updated with correct value after some user interaction, for example select text with value.

settings:

<AnimatedNumber
    value={value}
    stepPrecision={2}
    formatValue={(number) => number.toFixed(3).slice(0, -1)}
    duration={600}
/>

I've added shouldComponentUpdate to make sure another updates don't impact this, but this strange behavior still occurs sometimes on mobile.

Have you noticed something like this?

199911 commented 7 years ago

I got a similar problem, the number "stuck" at the end of animation

This is the screen cap when no missing frame animated-number

This is the screen cap when the bug appear The component's state currentValue stuck in "50" where currentTime updating animate-number-bug

Thyiad commented 5 years ago

I got similar problem, some times it's not right, not every times. How to fix it~~~