Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
238 views
in Technique[技术] by (71.8m points)

Has jQuery an 'animating'-event?

Has jQuery an animating-event (not :animated)? Something like step, but as extra method/event?

Currently I trigger a custom event in each animations step-function:

$('.foo').animate({property: 'value'}, {
    step: function(now, fx){
        $(this).trigger('animating', [now, fx])
    }
});

$('.foo').on('animating', function(e, now, fx){
    // do what you want
});

I think there's somewhere in the wild assuredly a better solution. Any ideas/approaches?

Update

I've written a (of course not awesome) special event, what make's handling this problem a bit easier:

(function($){
    var oldStep = $.fx.step._default;
    jQuery.event.special.animating = { };
    $.fx.step._default = function( fx ) {
        $(fx.elem).trigger('animating', fx);
        oldStep.apply( this, arguments );
    };
}(jQuery));

This doesn't work with jQuery 1.7+ since jQuery's animation method was changed, or rather the step function is not longer extendable ($.fx.step results in an empty object).

jQuery.fx refers to Tween.prototype.init; & jQuery.fx.step to {};

So it can't work...

I look still further on every tip!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...