Slider Jquery et chargement d'images
bonjour,
je viens à vous face à un problème rencontrer, ou plutot une difficulté rencontrée avec un script que j'ai fais : un petit slider basé sur jquery.
il fait donc s'afficher des images, les une après les autres avec un timer. mais la premiè-re image s'affiche toujours après la première boucle du timer (ici 5 secondes)
pourriez vous m'indiquer une piste pour régler cette légère prise de tête?
voici les codes javascript:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
function slideShow (container, speed) {
//Set the opacity of all images to 0
$(container+' li').css({opacity: 0.0});
//Get the first image and display it (set it to full opacity)
//if no IMGs have the show class, grab the first image
//ul.slideshow
var current = ($(container+' li.show')? $(container+' li.show') : $(container+' li:first'));
$(current).css({opacity: 1.0});
//Call the gallery function to run the slideshow
var timer = setInterval('gallery("'+container+'")',speed);
}
function gallery(container) {
//if no IMGs have the show class, grab the first image
var current = ($(container+' li.show')? $(container+' li.show') : $(container+' li:first'));
//Get next image, if it reached the end of the slideshow, rotate it back to the first image
var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption')? $(container+' li:first') :current.next()) : $(container+' li:first'));
//Set the fade in effect for the next image, show class has higher z-index
next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
//Hide the current image
current.animate({opacity: 0.0}, 1000).removeClass('show');
} |
et l'appel :
Code:
1 2 3 4 5 6
|
<script type="text/javascript">
$(document).ready(function() {
slideShow('ul.monslide',5000);
});
</script> |
merci par avance de vos réponses