Bug Tracker

Modify

Ticket #3583 (closed bug: fixed)

Opened 5 years ago

Last modified 4 years ago

too much recursion with animate( params, options ) [when options is a var]

Reported by: adrien.gibrat Owned by:
Priority: minor Milestone: 1.4.3
Component: effects Version: 1.4.2
Keywords: aminate, queueing, recursion, Cc:
Blocking: Blocked by:

Description

options.old (set in $.speed for queueing purpose) seems to store too much recursive call and freeze the browser when called more than x times, in firebug error message are:

too much recursion

fn.constructor != Array && /[\s[]?function/.test( fn + "" );

in jquery.js (ligne 619)

too much recursion

if ( jQuery.isFunction( opt.old ) )

in jquery.js (ligne 3158)

To resolve this bug:

speed: function(speed, easing, fn) { var opt = speed && speed.constructor == Object ? speed : {...}; ...

should be:

speed: function(speed, easing, fn) { var opt = speed && speed.constructor == Object ? jQuery.extend({},speed) : {...}; ...

Attachments

recursion-animation.html Download (1.1 KB) - added by adrien.gibrat 5 years ago.

Change History

Changed 5 years ago by adrien.gibrat

comment:2 Changed 4 years ago by cdmckay

I had this problem too.

Basically, if you re-use the "options" parameter object for many animations, you'll get a infinite loop.

Please update the animate() documentation to say that the "options" parameter is modified by animate() and cannot be re-used.

Better yet, why not make animate() make a copy of the "options" parameter object so that this bug will not occur anymore.

comment:3 Changed 4 years ago by cdmckay

This bug still occurs as of 1.4.2.

comment:4 Changed 4 years ago by desandro

 Stephen Rushing found a good work-around using $.extend inside $.fn.animate.

var animationOptions = {
    duration: 1000,
    easing: 'linear',
    queue: false
}

$(elem).animate(props, $.extend( true, [], animationOptions) )

comment:5 Changed 4 years ago by dmethvin

Agreed, we should either document options as mutated or make a copy.

comment:6 Changed 4 years ago by john

  • Status changed from new to closed
  • Version changed from 1.2.6 to 1.4.2
  • Resolution set to fixed
  • Milestone changed from 1.3 to 1.4.3

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.