Created
May 24, 2018 20:45
-
-
Save BenFausch/aa2f9036b4ed01ae84291de1a8ed764a to your computer and use it in GitHub Desktop.
Carousel slider logic for 3 piece carousel
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
var marginArray = ['0', '-100%', '-200%']; | |
var i = 0; | |
jQuery('#prev').click(function() { | |
i--; | |
i === -1 ? i = 2 : i; | |
jQuery('.slider-container').css('margin-left', marginArray[i]); | |
}); | |
jQuery('#next').click(function() { | |
i++; | |
i === 3 ? i = 0 : i; | |
jQuery('.slider-container').css('margin-left', marginArray[i]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment