How to extend jQuery's animate-step function
Asked Answered
C

1

6

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?

Coal answered 23/1, 2013 at 14:5 Comment(2)
Looks like the function is now at $.Tween.propHooks._default.set. But neither this one nor the old one are documented, so I'm not sure if this will behave the same.Knot
@Knot Noticed that already, however did not know that it is a replacer for the old function. Thanks, works well so far... (in jQuery's updates blog it is already flagged to be commented).Coal
C
1

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

Coal answered 28/5, 2013 at 23:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.