Skip to main content

Bug Tracker

Side navigation

#9067 closed bug (fixed)

Opened May 03, 2011 05:15PM UTC

Closed May 08, 2011 12:47AM UTC

.animate() array easing issue.

Reported by: sciolist.se@gmail.com Owned by: sciolist.se@gmail.com
Priority: high Milestone: 1.next
Component: effects Version: 1.6
Keywords: Cc:
Blocked by: Blocking:
Description

When attempting to perform an animation using:

  $("#test").animate({ opacity: [0, "swing"] });

no transition takes place, however, using:

  $("#test").animate({ opacity: 0, easing: { opacity: "swing" } });

works as expected.. You can fix the functionality by adding:

if(jQuery.isArray(val)) {
	(opt.specialEasing = opt.specialEasing || {})[name] = val[1];
	prop[name] = val[0];
}

at line 8030 of the full jquery source.. not at home, so can't supply a patch, sorry.

Attachments (0)
Change History (7)

Changed May 03, 2011 07:00PM UTC by dmethvin comment:1

owner: → sciolist.se@gmail.com
status: newpending

Can you provide a test case? Was this a regression from a previous version?

Changed May 03, 2011 07:03PM UTC by rwaldron comment:2

component: unfiledeffects

dmethvin, according to the docs, this wasn't supported. I wonder if the op meant to file as an enhancement?

Changed May 03, 2011 07:14PM UTC by sciolist.se@gmail.com comment:3

status: pendingnew

I'm pretty certain it was supported, if you look at http://api.jquery.com/animate/#per-property-easing, those arrays of ["toggle", "swing"] are no longer functioning.

The broken functionality is caused because on line 192 of animate (https://github.com/jquery/jquery/blob/master/src/effects.js#L194), there's a check to see if the value from the options set is an array, and it then uses the second item as an easing method.. unfortunately, it never resets the value to the first item, leading to jQuery attempting to animate say, opacity, to an array value.

The code was broken in change 7666c3ef, you can see the old code before that, (https://github.com/jquery/jquery/blob/eccf15be6cfee8b567785ba29cc8841b1b0c2ef1/src/effects.js#L186) which appropriately sets the value. Without having further inspected the problem, it may be possible to fix just by reverting that one line.

I'll write together a test case to demonstrate the issue.

Changed May 03, 2011 07:23PM UTC by threecreepio comment:4

http://jsfiddle.net/EpYH4/

demonstrates the issue, switch between 1.5 and 1.6 to see the difference.

Changed May 03, 2011 07:27PM UTC by timmywil comment:5

priority: undecidedhigh
status: newopen

yea, this is supported

Changed May 04, 2011 12:25AM UTC by threecreepio comment:6

there's a pull request for the issue: https://github.com/jquery/jquery/pull/369

Changed May 08, 2011 12:47AM UTC by Daniel Pihlstrom comment:7

resolution: → fixed
status: openclosed

Fix per-property easing. Fixes #9067

Changeset: 3d1c27d52ec667cea5735366a41f65344ab17a5e