Last active
January 4, 2016 07:59
-
-
Save drocarmo/8592590 to your computer and use it in GitHub Desktop.
How to optimize @content-directive in sass mixins
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
// Variables | |
$fade: fade; | |
$slideDown: slideDown; | |
$duration: 1s; | |
// Default Animation mixins | |
@mixin animation { | |
-webkit-animation-fill-mode: both; | |
animation-fill-mode: both; | |
-webkit-animation-duration: $duration; | |
animation-duration: $duration; | |
} | |
@mixin keyframes($name) { | |
@-webkit-keyframes #{$name} { | |
@content; | |
} | |
-moz-keyframes #{$name} { | |
@content; | |
} | |
-o-keyframes #{$name} { | |
@content; | |
} | |
@keyframes #{$name} { | |
@content; | |
} | |
} | |
// Specific animation ($fade) | |
.fade { | |
@include animation; | |
-webkit-animation-name: $fade; | |
-moz-animation-name: $fade; | |
-o-animation-name: $fade; | |
animation-name: $fade; | |
} | |
@include keyframes($fade) { | |
0% { | |
opacity: 0; | |
} | |
100% { | |
opacity: 1; | |
} | |
} | |
// Specific animation ($slideDown) | |
.slideDown { | |
@include animation; | |
-webkit-animation-name: $slideDown; | |
-moz-animation-name: $slideDown; | |
-o-animation-name: $slideDown; | |
animation-name: $slideDown; | |
} | |
@include keyframes($slideDown) { | |
0% { | |
-webkit-transform: translateY(-30px); | |
-ms-transform: translateY(-30px); | |
transform: translateY(-30px); | |
} | |
100% { | |
-webkit-transform: translateY(0px); | |
-ms-transform: translateY(0px); | |
transform: translateY(0px); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment