Created
March 28, 2024 06:53
-
-
Save cometkim/66298b913abbc49920f46b47acbefc0d to your computer and use it in GitHub Desktop.
Fake progress number, use the number with spring animation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nextProgress = (progress: number) => { | |
switch (true) { | |
case progress < 40: { | |
return progress + 40 + Math.random() * 10; | |
} | |
case progress < 60: { | |
return progress + 8 + Math.random() * 2; | |
} | |
case progress < 80: { | |
return progress + 3 + Math.random() * 2; | |
} | |
case progress < 90: { | |
return progress + Math.random() * 3; | |
} | |
case progress < 99: { | |
return progress + Math.random() * 1; | |
} | |
} | |
return progress + Math.log10(progress / 100) * -100; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment