Skip to main content

Bug Tracker

Side navigation

#10539 closed bug (fixed)

Opened October 20, 2011 07:09AM UTC

Closed December 04, 2012 05:44AM UTC

animate() might cause error in IE6-8

Reported by: abiao.chen Owned by:
Priority: low Milestone: 1.8
Component: effects Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:

On IE 6-8, some page will throw an error when calling

$("ul").animate({"left":"0%"}, 500)

After debugging, I found the animate() function(For 1.6.4, Line8286-8288) will compute start value by moving the element and testing the pixelLeft attribute. this, p, (end || 1) + unit);
	start = ((end || 1) / e.cur()) * start; this, p, start + unit);

The first line will call["left"]="1%"

to set the elem position. In IE6-8, this might NOT modify the pixelLeft attribute, for example the width of the containing block is 0. Thus, the e.cur() in the second line returns 0, and start value becomes NaN, which causes error in the later step( for 1.6.4, Line 8296).

For better robustness, I suggest to test the e.cur() return value in the second line, likes:

start = (e.cur() == 0) ? 0 : ((end || 1) / e.cur()) * start;

here is the test HTML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Page Title</title>
    <script type="text/javascript" src=""></script>
function move() {
    $("ul").animate({"left":"0%"}, 500);

    <a href='javascript:move()' style="left:0"><tr>click</tr></a>

    <div style="width:0">
        <ul style="left: 0%;">

Attachments (0)
Change History (3)

Changed October 20, 2011 09:23PM UTC by dmethvin comment:1

component: unfiledeffects
priority: undecidedlow
status: newopen

Changed January 12, 2012 06:29PM UTC by BiAiB comment:2

This bug has the side effect of not setting the timerId to false, which will block any further animate call. I think it's because of this line (8397):

if ( t() && jQuery.timers.push(t) && !timerId ) {

this totally freeze the application I work on. Here's my fix (~8207~8213 on v1.6.2):

	// We need to compute starting value
	if ( unit !== "px" ) { this, p, (end || 1) + unit);
		//bugfix IScope
		//start = ((end || 1) / e.cur()) * start;
		var cur = e.cur();
		start = cur==0?0:(((end || 1) / cur) * start); this, p, start + unit);

Changed December 04, 2012 05:44AM UTC by gibson042 comment:3

milestone: None1.8
resolution: → fixed
status: openclosed