Bonjour, je suis un débutant en javascript/jquery
J'ai crée un script qui lance le défilement des images. Le script fonctionne correctement sauf que la arriver à l'étape 2, le script n'éxécute plus les instructions comme je le souhaite, car il fait une pause plus importante que prévu puis éxécute 2 fois de suite la fonction.
voici l'adresse de la démo :http://www.godartmartin.com/test/
et voici le code
function scrollUl(u){
jQuery('ul.category-moduleimageSlider').stop();
jQuery('ul.category-moduleimageSlider').clearQueue();
clearTimeout(mytimer);
timeIn= true;
jQuery('ul.category-moduleimageSlider').animate({left: (u)},{duration: 3000, complete: nextStep});
};
function nextStep (){
jQuery('ul.category-moduleimageSlider').stop();
jQuery('ul.category-moduleimageSlider').clearQueue();
clearTimeout(mytimer);
if ( positionTableau<(counterImage-1)){
positionTableau++;
var ld = document.getElementById('imgdot'+ (positionTableau-1) +'');
ld.removeClass("selectedDot");
ge = (positionTableau);
var leftStep = arrayMidImage[ge];
var id = document.getElementById('imgdot'+ ge +'');
id.addClass("selectedDot");
var leftStep = arrayMidImage[ge];
mytimer=setTimeout(function(){
scrollUl(leftStep);
},6000);
delete ld;
delete id;
}
};
/*////*/
jQuery('.dot').click(function() {
jQuery('ul.category-moduleimageSlider').stop();
jQuery('ul.category-moduleimageSlider').clearQueue();
clearTimeout(mytimer);
jQuery('div.imgCounter div').each(function(){
jQuery(this).removeClass("selectedDot");
});
var id = jQuery(this).attr('id');
var childNbClick = id.split('imgdot');
var childNb = parseInt(childNbClick[1]);
var ghb = document.getElementById('imgdot'+ childNb +'');
positionTableau= childNb;
ghb.addClass("selectedDot");
if (childNb == 0){
jQuery('ul.category-moduleimageSlider').animate({ "left": startPosition}, "fast" );
}else{
stepPosition = arrayMidImage[childNb-1];
jQuery('ul.category-moduleimageSlider').animate({ "left": stepPosition}, "fast" );
}
ge = (positionTableau);
var leftStep = arrayMidImage[ge];
mytimer=setTimeout(function(){
scrollUl(leftStep);
},6000);
delete ghb;
});
merci à ceux qui pourront m'aider, le problème vient incontestablement des variables entre la position 1 et 2 mais je ne comprends pas pourquoi.
Partager