Replies: 2 comments 3 replies
-
|
That would be nice but how can we do this with CSS? |
Beta Was this translation helpful? Give feedback.
-
|
In fact it is pretty easy to do this.
Test:
Small tweaks to the JS test example: Fix some math calculations: https://play.tailwindcss.com/giXwOngI6x?file=css
Before and after can mostly be written as one rule (using the longer content), with only top and inline-inset-* different. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Going from 13 → 14: Both the 1 and 3→4 animate
Going from 19 → 20: Both digits animate (which makes sense here)
Proposed Enhancement
Implement smart digit animation where only the digits that actually change are animated:
Examples:
13 → 14: Only the second digit (3→4) animates, the 1 stays static
09 → 10: Both digits animate (as both changed)
19 → 20: Both digits animate (as both changed)
07 → 08: Only the second digit animates, the 0 stays static
59 → 00: Both digits animate (countdown wraps around)
Benefits
Cleaner Visual Experience: Users' eyes can focus on what's actually changing
More Professional Feel: Matches the behavior of high-end countdown timers
Accessibility: Less motion for digits that don't change reduces visual noise
Technical Implementation
This would require tracking the previous value of each digit individually and comparing them before applying the animation class. Only digits where currentDigit !== previousDigit would receive the animation.
Use Case
This is especially noticeable in countdowns with large numbers (e.g., days remaining) where the first digit might stay the same for extended periods. Having it unnecessarily animate every second creates visual distraction.
Would love to hear thoughts on this enhancement! Happy to contribute a PR if there's interest.
Next Steps
I'm ready to implement this feature and submit a PR. I've already built a working prototype that demonstrates this behavior perfectly.
Would the maintainers be open to:
Happy to adapt my implementation and match daisyUI's coding standards!
Beta Was this translation helpful? Give feedback.
All reactions