javascript - Anonymous function in setTimeout not working -
i'm trying create delay between 2 loops of nivo-slider.
without settimeout
works fine (but without delay). folloing example works:
$('#slider').nivoslider({ lastslide: function(){ $('#slider').data('nivo:vars').stop = true; // settimeout(function() { $('#slider').data('nivo:vars').stop = false; // }, 2000); }, });
if uncomment settimeout-lines slider stops not start again? ideas why?
update: http://jsfiddle.net/kgynx/
2nd update: tried wrapping function, too. function gets called if use settimeout in new function stops working: http://jsfiddle.net/kgynx/1/
solved different:
beforechange: function(){ $('#slider').data('nivo:vars').stop = true; var delay = 0; if ($('#slider').data('nivo:vars').currentslide == $('#slider').data('nivo:vars').totalslides - 2) { delay = 2000; } settimeout(function() { $('#slider').data('nivo:vars').stop = false; }, delay); }
i don't know why "totalslides - 2", works: http://jsfiddle.net/kgynx/15/
Comments
Post a Comment