Pretty simple situation. I have a function which calls it, it assigns text to variable “item”. Then valid selector grabs the object, fades it out for 500ms, until 0, waits 1 second, then puts the content of item in the object, and fades it in for 500ms, until entirely visible. Except it’s not how it works.
What actually happens is, I trigger it, the content changes, fade away starts, 1 second wait, fade in starts.
You can give the fadeOut a callback function, that will trigger when the fadeOut has completed.
Put the rest of the behaviour in the callback function, and you should be good.
Yes. That’s the solution. But why is it happening? Shouldn’t it fadeOut for 500 miliseconds, then wait 1 second (leaving it 500ms after fadeOut), change text and fadeIn back in?
The question is more why doesn’t it deliver expected result? Isn’t delay(t) suppose to delay the chain?
Still greatful for answer.
@edit - Yep, I checked it, it works perfectly. Still, why didn’t it work, is a wonder. Anyone want to explain ?
Shouldn’t that exactly mean, that (html and fadeIn) delayed is when 500 | fadeOut ends? Meaning that it should be delayed for 500ms more, after fadeOut, right?
[quote=“Webkitnote, post:5, topic:218724, full:true”]Shouldn’t that exactly mean, that (html and fadeIn) delayed is when 500 | fadeOut ends? Meaning that it should be delayed for 500ms more, after fadeOut, right?
[/quote]
No, and that’s the key point to notice here. The delay starts right away, not from the end of the animation.
If you want something to occur from the end of the animation, that’s where the callback is used.