Skip to content

Instantly share code, notes, and snippets.

@mrakowski0
Created March 29, 2013 13:38
Show Gist options
  • Select an option

  • Save mrakowski0/5270913 to your computer and use it in GitHub Desktop.

Select an option

Save mrakowski0/5270913 to your computer and use it in GitHub Desktop.
CSS Animation mixin
@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;
}
}
@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