Skip to content

Instantly share code, notes, and snippets.

@cometkim
Created March 28, 2024 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cometkim/66298b913abbc49920f46b47acbefc0d to your computer and use it in GitHub Desktop.
Save cometkim/66298b913abbc49920f46b47acbefc0d to your computer and use it in GitHub Desktop.
Fake progress number, use the number with spring animation
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