Skip to content

Instantly share code, notes, and snippets.

@joellesenne
Last active September 4, 2020 08:16
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 joellesenne/be6cbd988f3dbc579ee90a56b1154f85 to your computer and use it in GitHub Desktop.
Save joellesenne/be6cbd988f3dbc579ee90a56b1154f85 to your computer and use it in GitHub Desktop.
SASS Mixins for CSS animations
// SASS Mixins for CSS animations <https://joshbroton.com/quick-fix-sass-mixins-for-css-keyframe-animations/>
@mixin animation($animate...) {
$max: length($animate);
$animations: '';
@for $i from 1 through $max {
$animations: #{$animations + nth($animate, $i)};
@if $i < $max {
$animations: #{$animations + ", "};
}
}
-webkit-animation: $animations;
-moz-animation: $animations;
-o-animation: $animations;
animation: $animations;
}
/* How to use with <https://gist.github.com/joellesenne/ac064bf185dfb9ffe2627f3aeaf45e39>
.object-to-animate {
@include animation('move-the-object .5s 1', 'move-the-object-again .5s 1 .5s');
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment