Created
August 10, 2013 07:01
-
-
Save joshbroton/6199409 to your computer and use it in GitHub Desktop.
Sass mixins for cross-browser CSS animate and keyframe. @include animate() accepts multiple animations in a comma-separated list.
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
// animate with prefixes | |
// @include animation(ANIMATIONNAME LENGTH REPEAT INOUT,ANIMATIONNAME LENGTH REPEAT INOUT,ANIMATIONNAME LENGTH REPEAT INOUT); | |
@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; | |
} | |
// animation keyframes | |
// @include keyframes(ANIMATIONNAME) { | |
// 0% { ATTRIBUTE: VALUE; ATTRIBUTE: VALUE; } | |
// 50% { ATTRIBUTE: VALUE; ATTRIBUTE: VALUE; } | |
// 100% { ATTRIBUTE: VALUE; ATTRIBUTE: VALUE; } | |
// } | |
@mixin keyframes($animationName) { | |
@-webkit-keyframes #{$animationName} { | |
@content; | |
} | |
@-moz-keyframes #{$animationName} { | |
@content; | |
} | |
@-o-keyframes #{$animationName} { | |
@content; | |
} | |
@keyframes #{$animationName} { | |
@content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment