-
-
Save petarnonkovic/2f76e8dec3fffafd73636dd2d615547e to your computer and use it in GitHub Desktop.
scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; | |
} | |
@mixin keyframes($animationName) { | |
@-webkit-keyframes #{$animationName} { | |
@content; | |
} | |
@-moz-keyframes #{$animationName} { | |
@content; | |
} | |
@-o-keyframes #{$animationName} { | |
@content; | |
} | |
@keyframes #{$animationName} { | |
@content; | |
} | |
} | |
/* | |
Using the mixins looks like this: | |
@include keyframes(move-the-object) { | |
0% { left: 100px; } | |
100% { left: 200px; } | |
} | |
.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