Created
December 15, 2015 18:38
-
-
Save albybarber/bfa37f9f1b03030c40ad to your computer and use it in GitHub Desktop.
scss step 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
// This mixin takes the pain out of CSS step functions and has a non CSS3 fallback | |
// | |
// EXAMPLE: | |
// @include css-step-animation(ofo-welcome, 60, 'pages/one_funnel_onboarding/welcome.png', 12000px); | |
@mixin css-step-animation($name, $frames, $sprite-url, $sprite-length, $speed: 2s, $iteration-count: 1, $direction: normal, $fill-mode: forwards) { | |
$frame-width: $sprite-length / $frames; | |
background-image: image-url($sprite-url); | |
background-position: (-$sprite-length + $frame-width) 0; | |
background-repeat: no-repeat; | |
@at-root { | |
.css-transform-support & { | |
@include animation-fill-mode($fill-mode); | |
@include animation-name($name); | |
@include animation-duration($speed); | |
@include animation-timing-function(steps($frames - 1, end)); | |
@include animation-iteration-count($iteration-count); | |
@include animation-direction($direction); | |
background-size: auto 100%; | |
background-position: 0 0; | |
} | |
@include keyframes($name) { | |
to { | |
background-position: (-$sprite-length + $frame-width) 0; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment