Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Customizing animation repeat count and animation duration with utilities #17659

rozsazoltan started this conversation in Show and tell
Discussion options

Update

After understanding the implementation of variables, you can familiarize yourself with the animation-iteration-count and animation-duration property, which has been part of the baseline since 2015.

@import "tailwindcss";
/* Utility for Animation Timing */
@utility animate-duration-* {
 animation-duration: --value([*]);
 animation-duration: calc(--value(integer) * 1s);
}
/* Utility for Repeat Count */
@utility animate-repeat-* {
 animation-iteration-count: --value(integer, 'infinite', [*]);
}

Original Code

The other day, I created utilities for customizing the repeat count and timing of any animation. I’ll leave them here in case they are useful for someone else:

In the final solution, I was assisted by Wongjn's answer. The default animations can be overridden by using @theme inline instead of @theme to declare the animation. This doesn’t add any extra overhead if the animations used are already part of the project, as they will end up being part of the compiled CSS anyway.

Utility for Repeat Count - animate-repeat-*

@utility animate-repeat-* {
 --animate-bounce-count: --value(integer);
}
@utility animate-repeat-infinite {
 --animate-bounce-count: infinite;
}

Utility for Animation Timing - animate-duration-*

@utility animate-duration-* {
 --animate-duration: calc(--value(integer) * 1s);
}
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /