Created
October 22, 2012 14:10
-
-
Save Integralist/3931680 to your computer and use it in GitHub Desktop.
Sass Mixin for CSS3 Animations
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
@include keyframe(fadeout) { | |
0% { | |
opacity: 1; | |
} | |
100% { | |
opacity: 0; | |
} | |
} | |
@include keyframe(changecolour) { | |
0% { | |
color: #000; | |
} | |
100% { | |
color: #FFF; | |
} | |
} |
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
@mixin keyframe ($animation_name) { | |
@-webkit-keyframes $animation_name { | |
@content; | |
} | |
@-moz-keyframes $animation_name { | |
@content; | |
} | |
@-o-keyframes $animation_name { | |
@content; | |
} | |
@keyframes $animation_name { | |
@content; | |
} | |
} |
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
/* | |
Example usage: | |
@include animation(10s, 5s, changecolour) | |
*/ | |
@mixin animation ($delay, $duration, $animation) { | |
-webkit-animation-delay: $delay; | |
-webkit-animation-duration: $duration; | |
-webkit-animation-name: $animation; | |
-webkit-animation-fill-mode: forwards; /* this prevents the animation from restarting! */ | |
-moz-animation-delay: $delay; | |
-moz-animation-duration: $duration; | |
-moz-animation-name: $animation; | |
-moz-animation-fill-mode: forwards; /* this prevents the animation from restarting! */ | |
-o-animation-delay: $delay; | |
-o-animation-duration: $duration; | |
-o-animation-name: $animation; | |
-o-animation-fill-mode: forwards; /* this prevents the animation from restarting! */ | |
animation-delay: $delay; | |
animation-duration: $duration; | |
animation-name: $animation; | |
animation-fill-mode: forwards; /* this prevents the animation from restarting! */ | |
} |
I was having an error with this outputting the literal $animation_name
into the CSS. The accepted answer to this StackOverflow question resolved it for me. You might consider incorporating it into the gist.
I don't understand the examples or their relationship
Thank you very much
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I know this is a pretty old res, though it's missing animation-iteration-count, eg. use of infinite