jquery - How to set delay before append slideshow? -
i want append "image slideshow" on mouse hover image. works, want set delay on beginning slideshow. when set delay queue, stops working... why ? how fix ?
working jsfidlle example without delay
wrong jsfiddle example delay , queue
html
<ul> <li> <a href="http://cargocollective.com/jaimemartinez/" data-galeria="http://cssglobe.com/lab/tooltip/02/1.jpg,http://cssglobe.com/lab/tooltip/02/2.jpg,http://cssglobe.com/lab/tooltip/02/3.jpg,http://cssglobe.com/lab/tooltip/02/4.jpg" class="preview"> <img src="http://cssglobe.com/lab/tooltip/02/1.jpg" alt="gallery thumbnail"/> </a> </li> </ul>
jquery
this.imagepreview = function(){ xoffset = 10; yoffset = 30; var = 0; var interval = null; $("a.preview").hover(function(e){ data_galeria = $(this).data('galeria'); images = []; images = data_galeria.split(","); var hreff = images[0]; $("body").append("<p id='preview'><img id='preview_img' src='"+ hreff +"' alt='image preview' /></p>"); intervalid = setinterval(function () { = (i < 2) ? + 1 : 0; var image_src = images[i]; $('#preview_img').fadeout("fast", function(){ $('#preview_img').attr("src", image_src).hide(); $('#preview_img').fadein("slow"); }); }, 1800); $("#preview") .css("top",(e.pagey - xoffset) + "px") .css("left",(e.pagex + yoffset ) + "px") .fadein(); }, function(){ clearinterval(intervalid); $("#preview").remove(); }); $("a.preview").mousemove(function(e){ $("#preview") .css("top",(e.pagey - xoffset) + "px") .css("left",(e.pagex + yoffset) + "px"); }); }; $(function() { imagepreview(); });
css
#preview{ position:absolute; border:1px solid #ccc; background:#333; padding:5px; display:none; color:#fff; }
ok, found solution , mistake in code...
jquery
this.imagepreview = function(){ xoffset = 10; yoffset = 30; var = 0; var interval = null; $("a.preview").hover(function(e){ data_galeria = $(this).data('galeria'); images = []; images = data_galeria.split(","); var hreff = images[0]; $("body").append("<p id='preview'><img id='preview_img' src='"+ hreff +"' alt='image preview' /></p>"); intervalid = setinterval(function () { = (i < 2) ? + 1 : 0; var image_src = images[i]; $('#preview_img').fadeout("fast", function(){ $('#preview_img').attr("src", image_src).hide(); $('#preview_img').fadein("slow"); }); }, 1800); $("#preview") .css("top",(e.pagey - xoffset) + "px") .css("left",(e.pagex + yoffset ) + "px") .hide().delay(700).fadein(); }, function(){ clearinterval(intervalid); $("#preview").remove(); }); $("a.preview").mousemove(function(e){ $("#preview") .css("top",(e.pagey - xoffset) + "px") .css("left",(e.pagex + yoffset) + "px"); }); }; $(function() { imagepreview(); });
Comments
Post a Comment