diff options
author | Hailey <me@haileyok.com> | 2024-09-02 01:37:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-02 01:37:24 -0700 |
commit | 1225e8448524633466379d5ac00a78b53e1a9a51 (patch) | |
tree | 6215245576fed72912eeee9a51bcce01baf725ba /src/lib/custom-animations/util.ts | |
parent | eb868a042ad4f767b8e1b90d33bf1171b66a5238 (diff) | |
download | voidsky-1225e8448524633466379d5ac00a78b53e1a9a51.tar.zst |
Improve animations for like button (#5074)
Diffstat (limited to 'src/lib/custom-animations/util.ts')
-rw-r--r-- | src/lib/custom-animations/util.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/custom-animations/util.ts b/src/lib/custom-animations/util.ts new file mode 100644 index 000000000..0aebab57b --- /dev/null +++ b/src/lib/custom-animations/util.ts @@ -0,0 +1,21 @@ +// It should roll when: +// - We're going from 1 to 0 (roll backwards) +// - The count is anywhere between 1 and 999 +// - The count is going up and is a multiple of 100 +// - The count is going down and is 1 less than a multiple of 100 +export function decideShouldRoll(isSet: boolean, count: number) { + let shouldRoll = false + if (!isSet && count === 0) { + shouldRoll = true + } else if (count > 0 && count < 1000) { + shouldRoll = true + } else if (count > 0) { + const mod = count % 100 + if (isSet && mod === 0) { + shouldRoll = true + } else if (!isSet && mod === 99) { + shouldRoll = true + } + } + return shouldRoll +} |