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

Count down is slower than count up when end is 0 #287

Closed
ryancrunchi opened this issue Jul 6, 2022 · 2 comments · Fixed by #288 · 4 remaining pull requests
Closed

Count down is slower than count up when end is 0 #287

ryancrunchi opened this issue Jul 6, 2022 · 2 comments · Fixed by #288 · 4 remaining pull requests

Comments

@ryancrunchi
Copy link

ryancrunchi commented Jul 6, 2022

[x] Bug
[ ] Feature request

CountUp.js version: 2.3.1

Description

When the value goes from 0 to 7240 the duration is respected
When the value goes from 7240 to 0 the animation seems longer
When the value goes from 7240 to 1 the duration is respected

You can easily try in home page
Start 0, end 7240, duration 5, the duration is really 5 seconds
Start 7240, end 0, duration 5, the actual duration seems more 7s (40% longer)
Start 7240, end 1, duration 5, the duration is really 5 seconds
https://inorganik.github.io/countUp.js/

I can also view this difference in my production app with lower duration (0.5s when going up is 0.7s when going down) which makes my animations not synced.

@inorganik
Copy link
Owner

After some debugging, I found there's an issue with determineDirectionAndSmartEasing(), which is not halving duration as it should (only when counting down) when the second half of the animation runs. Smart easing breaks up the animation into 2 parts with equal durations but a smaller number in the second half so easing is visible.

So what's happening is the first half is half the set duration, but the second half is full duration meaning the animation is 150% as long as it should be. I will work on a fix.

inorganik added a commit that referenced this issue Jul 7, 2022
inorganik added a commit that referenced this issue Jul 8, 2022
* log animation duration

* small improvements

* fix the bug (#287)

* fix issue in determineDirectionAndSmartEasing

* clean up

* build
@inorganik
Copy link
Owner

Fixed in v2.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment