Skip to content

Instantly share code, notes, and snippets.

@NenadP
Last active August 29, 2015 14:09
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 NenadP/40f26e933485824245dc to your computer and use it in GitHub Desktop.
Save NenadP/40f26e933485824245dc to your computer and use it in GitHub Desktop.
scss keyframe animation mixin
/*
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