Search code examples
jquerydelay

.delay doesn't seem to delay .fadeOut/.fadeIn


I'm having an issue with the following line of code.

$("#chicken").delay(scrolllen).fadeOut(0).removeClass("flipped").css({ left: 900 + "px" , top : 2370 + "px"}).fadeIn(0).animate({ left: 1500 + "px" , top : 2370 + "px"}, 5000, 'linear');

So I'm having other animations happen. They take scrolllen so I have the delay so that it waits for the end of that animation. Then the item house vanish from where it is. The problem is, the .fadeOut is occuring immediately so I see the item vanish. Is there another way to achieve this?

http://jsfiddle.net/8dAqz/


Solution

  • I seem to have resolved this an alternate way.

    http://jsfiddle.net/8dAqz/1/

    By using the javascript function setTimeout and encompassing the jQuery calls within it, it stops as intended.