Created
March 29, 2013 13:38
-
-
Save mrakowski0/5270913 to your computer and use it in GitHub Desktop.
CSS Animation mixin
This file contains hidden or 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 animation ($name, $duration: 1s, $effect: linear, $delay: 0, $play-count: infinite, $direction: normal) { | |
| -webkit-animation: $name $duration $effect $delay $play-count $direction; | |
| -webkit-animation-fill-mode: forwards; /* this prevents the animation from restarting! */ | |
| -moz-animation: $name $duration $effect $delay $play-count $direction; | |
| -moz-animation-fill-mode: forwards; /* this prevents the animation from restarting! */ | |
| -o-animation: $name $duration $effect $delay $play-count $direction; | |
| -o-animation-fill-mode: forwards; /* this prevents the animation from restarting! */ | |
| animation: $name $duration $effect $delay $play-count $direction; | |
| animation-fill-mode: forwards; /* this prevents the animation from restarting! */ | |
| } | |
| @mixin keyframes ($animation_name) { | |
| @-webkit-keyframes $animation_name { | |
| @content; | |
| } | |
| @-moz-keyframes $animation_name { | |
| @content; | |
| } | |
| @-o-keyframes $animation_name { | |
| @content; | |
| } | |
| @keyframes $animation_name { | |
| @content; | |
| } | |
| } |
This file contains hidden or 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 keyframes(slide-left) { | |
| 0%,100% {left: 0px; opacity: 1;} | |
| 50% {left: -1500px; opacity: 0;} | |
| } | |
| @include keyframes(pulse) { | |
| 0%,100% {opacity: 0.01;} | |
| 50% {opacity: 0.66;} | |
| } | |
| .box { | |
| @include animation(slide-left, 5s, ease-out, 2s); | |
| } | |
| .scrolldown { | |
| @include animation(pulse, 2s); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment