Created
May 19, 2014 07:59
-
-
Save spoike/bcd9817f24bcec553b1b to your computer and use it in GitHub Desktop.
Sass mixin that emulates a CSS3 `steps()` animation function that works in earlier IE.CSS3 `steps()` function only works with >IE10 http://caniuse.com/css-animation
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 keyframesteps($name, $steps, $startx, $endx) { | |
| @keyframes #{$name} | |
| { | |
| @for $i from 0 through $steps { | |
| $diff: ($endx - $startx) / $steps; | |
| #{($i/$steps*100)}% { | |
| $x: ($i * $diff) + $startx; | |
| background-position: $x 0; | |
| } | |
| } | |
| } | |
| } | |
| /** | |
| * # Usage: | |
| */ | |
| @include keyframesteps(test, 4, 0px, -1080px); | |
| /** | |
| * # Will output to: | |
| @keyframes test { | |
| 0% { | |
| background-position: 0px 0; | |
| } | |
| 25% { | |
| background-position: -270px 0; | |
| } | |
| 50% { | |
| background-position: -540px 0; | |
| } | |
| 75% { | |
| background-position: -810px 0; | |
| } | |
| 100% { | |
| background-position: -1080px 0; | |
| } | |
| } | |
| * | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment