Bug Tracker

Opened 11 years ago

Closed 11 years ago

#12273 closed bug (fixed)

animate fails with 0 duration

Reported by: jarkaruus Owned by: gnarf
Priority: high Milestone: 1.8.1
Component: effects Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:

Description

Switching from 1.7.2 to 1.8 some plugins using animate with a duration of 0 don't animate at all in certain situations.

$(element).animate({ left: '-400px' }, 0, function() {}); // broken since 1.8
$(element).animate({ left: '-400px' }, 1, function() {}); // works

My guess is that a type check was changed into something else.

Change History (14)

comment:1 Changed 11 years ago by addyosmani

Component: unfiledeffects
Owner: set to jarkaruus
Priority: undecidedlow
Status: newpending

Thanks for submitting a ticket to the jQuery bug tracker. Could you reply back with a test case on jsFiddle.net reproducing the issue? If you could also test against jQuery-Git to ensure this hasn't been fixed by the latest version that would be appreciated.

comment:2 Changed 11 years ago by jarkaruus

Status: pendingnew

Here is the fiddle: http://jsfiddle.net/LQMzb/

The problem is there when having both jQuery UI 1.8.22 and jQuery 1.8 on the page.

comment:3 Changed 11 years ago by scottgonzalez

Hmm...this works against jQuery UI master, so it's probably a bug in UI. I'll dig into this today and find out which bug tracker this belongs in.

comment:4 Changed 11 years ago by scottgonzalez

What's happening is jQuery 1.8 now performs a single tick animation, while 1.7.2 skipped the animation. Was that an intentional change? This breaks in old jQuery UI because the easing equations that everybody uses (including jQuery UI) rely on duration. jQuery UI master works because we rewrote all easing equations to only rely on state. So this is a breaking change. We can fix it in jQuery UI 1.8.23, but anyone using the easing plugin on its own will have broken animations for a duration of 0.

comment:5 Changed 11 years ago by scottgonzalez

This is now fixed in jQuery UI 1-8-stable and will be included in 1.8.23 this week. See http://bugs.jqueryui.com/ticket/8493.

comment:6 Changed 11 years ago by jarkaruus <ts.jarkaruus@…>

Awesome, thanks

comment:7 Changed 11 years ago by jarkaruus

Now that the extra easing equations have been reduced to a few lines of code maybe it makes sense to move them into jQuery so all of them are in one place?

comment:8 Changed 11 years ago by sindresorhus

Resolution: fixed
Status: newclosed

comment:9 Changed 11 years ago by scottgonzalez

@sindresorhus I didn't see any commits for this, how did it get fixed?

Last edited 11 years ago by scottgonzalez (previous) (diff)

comment:10 Changed 11 years ago by gnarf

Milestone: None1.8.1
Priority: lowhigh
Resolution: fixed
Status: closedreopened

comment:11 Changed 11 years ago by gnarf

The issue here is passing a 0 duration to an easing function, if the duration is 0 it probably should skip easing altogether.

comment:12 Changed 11 years ago by gnarf

Owner: changed from jarkaruus to gnarf
Status: reopenedassigned

comment:14 Changed 11 years ago by Corey Frang

Resolution: fixed
Status: assignedclosed

Fix #12273. Don't call easing functions for duration 0 animations. Close gh-895.

Changeset: 0fea007a1a4d6456a8c7d246e4f7a4e14a1ba04a

Note: See TracTickets for help on using tickets.