rstacruz / jquery.transit

Super-smooth CSS3 transformations and transitions for jQuery
http://ricostacruz.com/jquery.transit
7.3k stars 864 forks source link

deferring until after transition on chain? #211

Open frumbert opened 9 years ago

frumbert commented 9 years ago

Say I have an effect with chaining

$(".thing").on("mouseover", function () {
    $(this).transition({scale: 1.2}, 1500).transition({perspective: '100px', rotateY: '180deg'}).css("border","2px solid red");
});

The "css" property set (changing border) is applied right away, whereas perspective is applied after scale as per the animation queue.

Is there a way to defer subsequent chained object execution until after all your transitions finish? E.g. scale, then flip, then add class? So then you could:

$(obj).transition({scale: 0}).hide();
kilometers commented 9 years ago

I could be crazy here, but it sounds like you can use the callback in the second .transition(...)

Here's what it could look like (untested)

$(".thing").on("mouseover", function () {
    $(this)
        .transition({scale: 1.2}, 1500)
        .transition({perspective: '100px', rotateY: '180deg'}, function(){$(this).css("border","2px solid red")}.bind(this));
});