I am looking for some function that:
- would be able to wait for all effects in the queue to finish
- could be used in the classical jQuery call sequence
Example:
I want to do some animations and then some operations after they finish:
$('.obs_list')
.delay(500)
.animate({
'background-color' : '#ffcc33'
}, 200)
.delay(1000)
.animate({
'background-color' : 'transparent'
}, 2000)
.THE_FUNCTION_I_AM_LOOKING_FOR()
.css({ 'color' : 'red' }) // this should come *after* the effects above are finished
...
I want to avoid the complete
callback of the animate function since you have to call jquery again inside it, it is not very elegant and breaks the chain:
...
.animate({
'background-color' : 'transparent'
}, 2000, function () {
$(this)
.css({ 'color' : 'red' })
...
});
I hate this solution.
I tried to use .promise()
but this breaks the chain too as it apparently doesn't return the proper jQuery object. And please avoid writing new plugin :-)