Created
October 28, 2011 14:11
-
-
Save MiLk/1322364 to your computer and use it in GitHub Desktop.
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 retour = true; | |
var tempsTransition = 1000; | |
var lectureAutomatique = true; | |
var tempsAttente = 6000; | |
var interval; | |
var lectureEnCours = false; | |
var currentPosition = 0; | |
var slideWidth = 780; | |
$(document).ready(function(){ | |
var slides = $('.slide'); | |
var numberOfSlides = slides.length; | |
// Supprime la scrollbar en JS | |
$('.slidesContainer').css('overflow', 'hidden'); | |
slides | |
.wrapAll('<div id="slideInner"></div>') | |
// on met tous les slides en float:left pour qu'il s'affichent de manière horizontale | |
.css({ | |
'float' : 'left', | |
'width' : slideWidth | |
}); | |
// La longueur de #slideInner équivaut à la somme de la longueur de tous les slides | |
$('#slideInner').css('width', slideWidth * numberOfSlides); | |
// crée un écouteur pour l'évènement de type clic sur les div qui ont la classe .control | |
$('.slideshow .slideshow_controler a').click(function(){ | |
$(this).parent().children(".control_on").removeClass("control_on").addClass("control_off"); | |
$(this).removeClass("control_off").addClass("control_on"); | |
// Determine une nouvelle position | |
currentPosition = $(this).attr('rel'); | |
// Move slideInner using margin-left | |
$('#slideInner').animate({ | |
'marginLeft' : slideWidth*(-currentPosition) | |
},tempsTransition); | |
}); | |
if(lectureAutomatique == true){ | |
start(); | |
} | |
}); | |
function start() { | |
lectureEnCours = true; | |
interval = setInterval(suivant, tempsAttente ); | |
} | |
function suivant(){ | |
currentPosition = (parseInt(currentPosition) == 3) ? 0 : parseInt(currentPosition) + 1; | |
$(".slideshow .slideshow_controler").children(".control_on").removeClass("control_on").addClass("control_off"); | |
$(".slideshow .slideshow_controler a[rel="+currentPosition+"]").removeClass("control_off").addClass("control_on"); | |
// Move slideInner using margin-left | |
$('#slideInner').animate({ | |
'marginLeft' : slideWidth*(-currentPosition) | |
},tempsTransition); | |
} | |
function pause() { | |
lectureEnCours = false; | |
clearInterval(interval); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment