Last active
February 20, 2017 06:48
-
-
Save danyalette/0c32184b9a86a31e061c785e114f2528 to your computer and use it in GitHub Desktop.
pure scss slideshow
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
$images: "/images/fun.jpg", "/images/yay.jpg", "/images/wow.jpg"; | |
$slide_duration: 2s; | |
//preload images | |
body:before { | |
$urls: url(''); | |
@each $image in $images { | |
$urls: $urls + url(#{$image}) ; | |
} | |
display: none; | |
content: $urls; | |
} | |
@keyframes slideshow { | |
$current_percentage: 0; | |
$increment: 100/length($images); | |
@each $image in $images { | |
#{$current_percentage}% { background-image: url($image); } | |
$current_percentage: $current_percentage + $increment; | |
} | |
} | |
.slideshow-image { | |
animation-name: slideshow; | |
animation-timing-function: step-end; | |
animation-fill-mode: forwards; | |
animation-duration: $slide_duration * length($images); | |
animation-iteration-count: infinite; | |
background-size: cover; | |
background-position: center; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment