Last active
August 29, 2015 13:57
-
-
Save pixelthing/9782842 to your computer and use it in GitHub Desktop.
SASS 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
/* animation mixins */ | |
@import "compass/css3/shared" | |
@mixin animation ($animation_name, $duration: 500ms, $fill_mode: forwards, $iteration_count: 1, $delay: 0, $direction: normal, $timing_function: ease) | |
+experimental(animation-name, $animation_name) | |
+experimental(animation-duration, $duration) | |
@if $fill_mode != none | |
+experimental(animation-fill-mode, $fill_mode) | |
@if $iteration_count != 1 | |
+experimental(animation-iteration-count, $iteration_count) | |
@if $delay != 0 | |
+experimental(animation-delay, $delay) | |
@if $direction != normal | |
+experimental(animation-direction, $direction) | |
@if $timing_function != ease | |
+experimental(animation-timing-function, $timing_function) | |
@mixin keyframe ($animation_name) | |
@-webkit-keyframes #{$animation_name} | |
@content | |
@-moz-keyframes #{$animation_name} | |
@content | |
@keyframes #{$animation_name} | |
@content | |
/* example animation */ | |
@include keyframe(pointypoint) | |
0% | |
+transform(translateY(0)) | |
50% | |
+transform(translateY(10px)) | |
100% | |
+transform(translateY(0)) | |
.bob:hover | |
@include animation(pointypoint, 500ms, forwards, infinite) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated based on some ace work by @annez (as usual) https://gist.github.com/annez/9783177