Created
February 5, 2014 21:53
-
-
Save nick-jonas/8833982 to your computer and use it in GitHub Desktop.
Compass Keyframe Animation
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
@import "compass/css3/transform"; | |
@import "compass/css3/transition"; | |
@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; | |
} | |
} | |
// use of keyframes mixin | |
@include keyframes(animate-object) { | |
0% { | |
top:30px; | |
opacity:1; | |
} | |
100% { | |
top:120px; | |
opacity:0; | |
} | |
} | |
.object{ | |
@include animation('animate-object 1s infinite'); | |
width:193px; | |
height:auto; | |
position:absolute; | |
top: 120px; | |
left: 65px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment