Bug Tracker

Opened 4 years ago

Closed 4 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 4 years ago by addyosmani

  • Component changed from unfiled to effects
  • Owner set to jarkaruus
  • Priority changed from undecided to low
  • Status changed from new to pending

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 4 years ago by jarkaruus

  • Status changed from pending to new

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 4 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 4 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 4 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 4 years ago by jarkaruus <ts.jarkaruus@…>

Awesome, thanks

comment:7 Changed 4 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 4 years ago by sindresorhus

  • Resolution set to fixed
  • Status changed from new to closed

comment:9 Changed 4 years ago by scottgonzalez

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

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

comment:10 Changed 4 years ago by gnarf

  • Milestone changed from None to 1.8.1
  • Priority changed from low to high
  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:11 Changed 4 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 4 years ago by gnarf

  • Owner changed from jarkaruus to gnarf
  • Status changed from reopened to assigned

comment:14 Changed 4 years ago by Corey Frang

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

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

Changeset: 0fea007a1a4d6456a8c7d246e4f7a4e14a1ba04a

Note: See TracTickets for help on using tickets.