Bug Tracker

Opened 9 years ago

Closed 6 years ago

Last modified 5 years ago

#2408 closed bug (duplicate)

Executing the stop() method causes corruption of element's original attributes

Reported by: DanSwitzer2 Owned by: john
Priority: high Milestone:
Component: effects Version: 1.4.4
Keywords: animate stop Cc:
Blocked by: Blocking:


When you execute the stop() method on an animation, some corruption to the original element can occur. This is because the animate() method automatically changes some properties of the element in order to get the correct visual effect.

In normal circumstances the original state of the element is restored during the step() method when the "done" condition is true.

The problem is when you call the stop() method on an element these original properties are overwritten with properties of the element in it's current stopped state.

The easiest way to see this bug is on this example page: http://www.pengoworks.com/workshop/jquery/stop_bug.htm

If you click the "Timed Animation" button you'll see that the "overflow" on "Menu 1" is lost.

This is because midway through the animation queue, the stop() method is called on the element. Since the animate() method automatically sets the overflow to hidden (for animating height,) after the stop() method is called and we attempt to restore the element to it's original height, the animate() method sees that the overflow is currently set to "hidden" and therefore never properly removes the overflow value when the animation is done.

I've been able to fix this by tracking the original properties of the element and then clearing the settings once the queue is emptied.

See the following example of my patched code: http://www.pengoworks.com/workshop/jquery/stop_bug_fix.htm

You'll notice that on this same example, the element's overflow is correctly reset once the queue clears.

A diff of my changes can be found here: http://www.pengoworks.com/workshop/jquery/lib/jquery.anim.fix.txt

The main change I did was implement a variable to track the original properties of the element and this gets reset once the animation queue is empty.

Change History (7)

comment:1 Changed 9 years ago by DanSwitzer2

After finally reading up about the $.data() method, I'd move the tracking of the original properties to use the $.data() method instead of a variable.

comment:2 Changed 7 years ago by Kanuck

This bug is kicking my ass right now. I attached the simplest example I could think up.

Confirmed to still exist in jQuery 1.4.2.

In short, this:

$("#slidefade").hover(function() {
		'opacity' : 'toggle',
		'height' : 'toggle'
	}, 1000);

is not working as expected, because stop() is interfering with animate()'s ability to correctly remember the object's "on" state.

comment:3 Changed 6 years ago by snover

  • Milestone changed from 1.2.4 to 1.5
  • Priority changed from major to high
  • Status changed from new to open
  • Version changed from 1.2.3 to 1.4.4

comment:4 Changed 6 years ago by ajpiano

  • Milestone set to 1.7
  • Owner set to john
  • Status changed from open to assigned

comment:5 Changed 6 years ago by john

  • Resolution set to duplicate
  • Status changed from assigned to closed

We're going to work on this over in: #8685.

comment:6 Changed 6 years ago by john

Duplicate of #8685.

comment:7 Changed 5 years ago by dmethvin

  • Milestone 1.7 deleted
Note: See TracTickets for help on using tickets.