Last active
August 29, 2015 14:09
-
-
Save NenadP/40f26e933485824245dc to your computer and use it in GitHub Desktop.
scss keyframe animation mixin
This file contains 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
/* | |
Handy for keyframe animations (spritesheed cycling for example) | |
Usage example: | |
@include keyframe-animation(animation-name, .8s, 5, infinite); | |
@include animation-keys("animation-name") { | |
from { background-position: 0 0; } | |
to { background-position: 0 -200px; } | |
} | |
*/ | |
@mixin keyframe-animation($animation-name, $duration, $steps-num, $times) { | |
-webkit-animation: $animation-name $duration steps($steps-num) $times; | |
-moz-animation: $animation-name $duration steps($steps-num) $times; | |
-ms-animation: $animation-name $duration steps($steps-num) $times; | |
-o-animation: $animation-name $duration steps($steps-num) $times; | |
animation: $animation-name $duration steps($steps-num) $times; | |
} | |
@mixin animation($animation-name, $duration, $easing, $times) { | |
-webkit-animation: $animation-name $duration $easing $times; | |
-moz-animation: $animation-name $duration $easing $times; | |
-ms-animation: $animation-name $duration $easing $times; | |
-o-animation: $animation-name $duration $easing $times; | |
animation: $animation-name $duration $easing $times; | |
} | |
@mixin animation-keys($animation-name) { | |
@-webkit-keyframes #{$animation-name} { | |
@content | |
} | |
@-moz-keyframes #{$animation-name} { | |
@content | |
} | |
@-ms-keyframes #{$animation-name} { | |
@content | |
} | |
@-o-keyframes #{$animation-name} { | |
@content | |
} | |
@keyframes #{$animation-name} { | |
@content | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment