If a timeout is required to make the animation happen, then you should add a delay
:
$('body')
.append($block)
.delay(0)
.queue(function (next) {
$block.addClass('shifted');
next(); //don't forget to dequeue so that the rest of the queue can run
});
.delay()
is really just a convenience method for:
.queue(function (n) {
setTimeout(n, duration);
});
If you don't call delay
(or queue a timeout), the fx queue will execute immediately, which defeats the purpose of queuing $block.addClass('shifted')
.