Created
January 5, 2016 17:08
-
-
Save xDarkicex/5bfb334cee7b1a0469fc to your computer and use it in GitHub Desktop.
broken Slider
This file contains hidden or 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 sliderIndex = 0; | |
| var $images = $(".slide-group").children(); | |
| function slide(){ | |
| $images.fadeOut(); | |
| $($images[sliderIndex]).slideDown(); | |
| sliderIndex = (sliderIndex<$images.length-1)?sliderIndex+1:0; | |
| } | |
| function validate() { | |
| if (document.getElementById('remember').checked) { | |
| refreshIntervalId = window.setInterval(slide, 1000); | |
| } else { | |
| window.clearInterval(refreshIntervalId) | |
| refreshIntervalId = null; | |
| } | |
| } | |
| var refreshIntervalId; | |
| $(function(){ | |
| var $bar = $('.slide-buttons'); | |
| addButton("Previous", prev, $bar); | |
| addButton("Next", next, $bar); | |
| }) | |
| function next(){ | |
| sliderIndex = (sliderIndex<$images.length-1)?sliderIndex+1:0; | |
| slide(); | |
| } | |
| function prev(){ | |
| sliderIndex = (sliderIndex<0)?sliderIndex-1:$images.length-1; | |
| slide(); | |
| } | |
| function addButton(name, click, $element){ | |
| var $button = $("<button>"); | |
| $button.text(name); | |
| $button.on('click', click); | |
| $element.append($button); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment