Last active
March 9, 2017 08:18
-
-
Save mfd/dc85ee13d53a8aa7403669f069ffe39e to your computer and use it in GitHub Desktop.
items animation mixin
This file contains 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
// Add body.loaded after page loaded | |
// window.onload = function() { document.body.classList.add('.loaded'); }; | |
// $(function() { $('body').addClass('loaded'); }); | |
// or | |
// Add .loaded for viewport area on page | |
//@include anim('.logo h1', 'translateY(20px)', 540ms ); | |
@mixin anim($class, $transform, $animDelay:0.1s, $start: '.loaded', $transition: 'all 320ms ease-out' ) { | |
#{$class} { | |
opacity: 0; | |
transition: #{$transition}; | |
transform: #{$transform}; | |
#{$start} & { | |
opacity: 1; | |
transform:none; | |
transition-delay: #{$animDelay}; | |
} | |
} | |
} | |
//@include anim-items('.navbar-nav li', 'translateX(-16px)', 300ms ); | |
@mixin anim-items($class, $transform, $animDelay: 0.2s, $start: '.loaded', $transition: 'all 320ms ease-out', $n: 50) { | |
@include anim($class, $transform); | |
@for $i from 1 through $n { | |
#{$start} #{$class}:nth-child(#{$i}) { | |
transition-delay: ($animDelay + ($i - 1) * 0.1s); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment