Opened 14 years ago
Closed 12 years ago
#3583 closed bug (fixed)
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: | |
Blocked by: | Blocking: |
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 (1)
Change History (6)
Changed 14 years ago by
Attachment: | recursion-animation.html added |
---|
comment:2 Changed 13 years ago by
comment:4 Changed 13 years ago by
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 12 years ago by
Agreed, we should either document options as mutated or make a copy.
comment:6 Changed 12 years ago by
Milestone: | 1.3 → 1.4.3 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Version: | 1.2.6 → 1.4.2 |
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.