Last active
December 10, 2015 14:29
-
-
Save toledox82/4448230 to your computer and use it in GitHub Desktop.
JavaScript: jQuery Slider 3
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
/*! | |
* Toledo Interactive jQuery Slider Script III | |
* Developed for http://inteface.eng.br | |
* | |
* Copyright 2012, Toledo Interactive | |
* http://toledointeractive.com/ | |
* | |
* Usage: Slider.init(); | |
* | |
*/ | |
var Slider = { | |
count: 0, | |
interval: '', | |
time: 6000, | |
slider: 'body > header', | |
items: '#featured article', | |
images: '#featured .image', | |
nextButton: '#featured .control .proximo', | |
prevButton: '#featured .control .anterior', | |
running: false, | |
init: function(){ | |
Slider.slider = $(Slider.slider); | |
Slider.items = $(Slider.items); | |
Slider.images = $(Slider.images); | |
Slider.items.hide(); | |
Slider.images.hide(); | |
// Slider.slider.on({ | |
// mouseenter: function() { Slider.stop(); }, | |
// mouseleave: function() { Slider.start(); } | |
// }); | |
$(Slider.nextButton).on({ | |
click: function(e) { | |
e.preventDefault(); | |
Slider.next(); | |
} | |
}); | |
$(Slider.prevButton).bind({ | |
click: function(e) { | |
e.preventDefault(); | |
Slider.prev(); | |
} | |
}); | |
Slider.first(); | |
}, | |
first: function(){ | |
Slider.running = true; | |
Slider.items.eq(0).css('top','-200px'); | |
Slider.images.eq(0).fadeIn(1000); | |
Slider.items.eq(0).show(); | |
Slider.items.eq(0).delay(1000).animate({ | |
top: '100px' | |
}, 500, 'easeOutQuad', function(){ | |
Slider.running = false; | |
Slider.start(); | |
}); | |
}, | |
start: function(){ | |
Slider.interval = window.setInterval('Slider.next()', Slider.time); | |
}, | |
stop: function(){ | |
clearInterval(Slider.interval); | |
}, | |
next: function(){ | |
if ( Slider.running == true) { return false; } | |
Slider.clear(); | |
Slider.count++; | |
if(Slider.count == Slider.items.length) Slider.count = 0; | |
Slider.change(); | |
}, | |
prev: function(){ | |
if ( Slider.running == true) { return false; } | |
Slider.clear(); | |
Slider.count--; | |
if(Slider.count < 0) Slider.count = Slider.items.length - 1; | |
Slider.change(); | |
}, | |
clear: function() { | |
Slider.items.stop(true,true); | |
Slider.images.stop(true,true); | |
}, | |
change: function(){ | |
Slider.running = true; | |
Slider.items.fadeOut(500); | |
Slider.images.delay(500).fadeOut(500); | |
Slider.items.eq(Slider.count).css('top','-200px'); | |
Slider.images.eq(Slider.count).fadeIn(1000); | |
Slider.items.eq(Slider.count).show(); | |
Slider.items.eq(Slider.count).delay(1000).animate({ | |
top: '100px' | |
}, 500, 'easeOutQuad', function(){ | |
Slider.running = false; | |
}); | |
}, | |
goto: function(i){ | |
Slider.count = i; | |
Slider.change(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment