javascript - How to evenly time fading transitions? -
so i'm trying create simple slide show scratch, , far able full screen images fade out , fade in infinetly, odd reason using setinterval(function(){fade(var)}, 3500);
didn't work, maybe can explain why first , last images took way longer 3,5 seconds fade. meanwhile, trying solve problem implementing callback function in fade()
. example has 4 images, , start fading out until reaches image one, don't fade out image 1 , start fading in image 2 until image 4, , forever, here recent attempt implement callback function:
var = 4; $(document).ready(function(){ fade(i, fade); }); var fadein = false; function fade(objectid, callbackfn){ var fadetime = 3500; if(!fadein){ $("#slide-"+objectid).fadeout(fadetime); i--; if(i === 1) { fadein = true; } } else{ i++; $("#slide-"+objectid).fadein(fadetime); if(i === 4){ fadein = false; } } if(arguments[1]){ callbackfn(i); } }
but not working, fades out image 4, image 3 , stops on image 2. maybe there way evenly time fading transitions using setintervel()
, if can tell me how? appreciate help.
here jsfiddle code: http://jsfiddle.net/8kgc0chq/ not working tho.
here doc .fadeout()
there optional argument complete
:
a function call once animation complete.
put next animation in there, take complete
(callback) function.
$("#id").fadeout(fadetime, function() { // code execute after animation complete });
Comments
Post a Comment