Last active
June 20, 2017 00:18
-
-
Save brybrophy/36a09de3e1747813bed6bae63d5b5625 to your computer and use it in GitHub Desktop.
A SASS mixin to slide an element in any cardinal direction, at any speed, for any distance.
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
// example 1: @include slide(up, 125ms, 100%); | |
// example 2: No distance required for "off" @include slide(off, 125ms); | |
// example 3: | |
// div { | |
// @include slide(up, 250ms, 100%); | |
// | |
// &.is-visible { | |
// @include slide(off, 125ms); | |
// } | |
// } | |
@function slide($direction, $distance) { | |
$slide: ( | |
down: translateY($distance), | |
left: translateX(-$distance), | |
off: translate(0, 0), | |
right: translateX($distance), | |
up: translateY(-$distance) | |
); | |
@return map-get($slide, $direction); | |
} | |
@mixin slide($direction, $speed, $distance: 0) { | |
transform: slide($direction, $distance); | |
transition: all $speed ease-in-out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment