Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend jQuery's animate-step function

Any ideas how to extend the step-function in jQuery 1.6+?

I've made a special-event to trigger a custom-event on each animated step. However since jQuery's animation method was changed, or rather the step function is not longer extendable ($.fx.step results in an empty object) is it impossible to extend it with your own things.

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

$('#foo').animate({width: 200});
$('#foo').bind('animating', function(e, fx){
    console.log(fx);
});

Any ideas how to get this to work with newer jQuery versions?

like image 634
yckart Avatar asked Jan 23 '13 14:01

yckart


Video Answer


1 Answers

Got it, in jQuery's updates-blog, this is already flagged to be commented.

like image 57
yckart Avatar answered Nov 15 '22 10:11

yckart