Skip to main content

Bug Tracker

Side navigation

#2042 closed bug (fixed)

Opened December 12, 2007 10:00AM UTC

Closed February 14, 2009 07:52PM UTC

callback parameter doesn't match on animate functions

Reported by: beat Owned by:
Priority: major Milestone: 1.2.4
Component: effects Version: 1.2.1
Keywords: animate parameters Cc:
Blocked by: Blocking:

Sorry to bother, maybe i'm seing wrong, but callback parameter doesn't match on animate function's parameter, it goes into "easing":

fadeTo: function(speed,to,callback){

return this.animate({opacity: to}, speed, callback);


animate: function( prop, speed, easing, callback ) {

slideDown, slideUp, slideToggle, fadeIn, fadeO, fadeTo functions seem to have same bug.

Attachments (0)
Change History (12)

Changed December 12, 2007 03:47PM UTC by davidserduke comment:1

need: ReviewTest Case
resolution: → worksforme
status: newclosed

Are you seeing a bug associated with this or is this from looking at the code?

If it is the former then please put together a descrition or test case of the problem. If it is the latter then read on.

If you look at the wiki documentation:

You'll see the easing parameter is optional. The way jQuery handles optional parameter is through parameter testing. So in this case, if you look at the first line of the animate() function:

You'll see

var optall = jQuery.speed(speed, easing, callback);

which is the optional parameters passed in to the .speed() function.

Now if you look at the .speed() function

you'll see various parameter checking to make sure functions exist and such. It can get pretty complicated with multiple optional parameters which most of jQuery does not do. Typically there is only one optional parameter.

var opt = speed && speed.constructor == Object ? speed : { 
        complete: fn || !fn && easing ||  
                  jQuery.isFunction( speed ) && speed, 
        duration: speed, 
        easing: fn && easing || easing && easing.constructor != Function && easing 

This code above handles the optional parameters.

That said, if you see an actual problem please feel free to reopen the ticket with a test case. Hope that helps explain what's going on because I agree it can be complicated in this instance.

Changed January 30, 2008 11:32AM UTC by tgdavies comment:2

resolution: worksforme
status: closedreopened

This does cause a problem, as hide(), for instance, doesn't pass an easing parameter, so if the callback is provided, then animate() gets confused.

The error message I get is: Value undefined (result of expression jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")]) is not object.

And the element disappears all at once.

I think the problem is that hide() doesn't pass an 'easing' parameter to animate() -- this is ok when there's no callback, but when there is a callback animate() confuses the callback with the easing param. I can fix the problem by passing null for the easing param at line 2888

Changed January 30, 2008 05:36PM UTC by davidserduke comment:3

Can you provide a test case or some code that shows what the problem is? What exactly are you writing that gives you an error?

Changed January 31, 2008 10:39AM UTC by tgdavies comment:4

I'm getting this problem when I wrap hide() using GWT. The GWT code is:

public class JQuery
    public static interface Callback {
        public void fn();
    public static native void hide(Element e, int speed, Callback callback) /*-{
       $wnd.jQuery(e).hide(speed, function() { callback.@com.atlassian.crucible.gwt.client.JQuery.Callback::fn()(); });

Which may not mean too much to you if you aren't familiar with GWT.

The generated code is:

function hide(e, speed, callback){
  $wnd.jQuery(e).hide(speed, function(){

Note the use of $wnd -- the compiled GWT Javascript runs in a nested frame, and $wnd refers to the host window -- perhaps that's the problem?

Note that I *can* fix the problem by modifying hide() so that it explicitly passes null to animate for the easing parameter.

Changed January 31, 2008 06:09PM UTC by davidserduke comment:5

Hmm, I haven't done much more with GWT then install it and run a few examples so...

But I agree it sounds like a frame issue. I see in jQuery.speed() it says:

  easing: fn && easing || easing && easing.constructor != Function && easing

I wonder why that last easing is there? Anyway that's off topic. Can you try patching it to this?

  easing: fn && easing || easing && !jQuery.isFunction(easing.constructor)

The != Function part looks to me like it would fail across frames.

Changed February 01, 2008 11:32AM UTC by tgdavies comment:6

Hi David,

That change fixes the problem.

Will it get committed?



Changed February 04, 2008 04:18AM UTC by tgdavies comment:7

easing: fn && easing || easing && !jQuery.isFunction(easing.constructor)

assigns 'true' or 'false' to the 'easing' attribute, instead of the value of 'easing' -- that was why the last easing is there.


easing: fn && easing || easing && !jQuery.isFunction(easing.constructor) && easing

would be correct

Changed February 04, 2008 05:18PM UTC by davidserduke comment:8

need: Test CaseCommit

Ahh good point. I should have known it wasn't a mistake. :)

In fact it could also be

easing: fn && easing || !jQuery.isFunction(easing.constructor) && easing

since jQuery.isFunction() checks the parameter is truthy.

As for getting committed, I'm sure it will eventually. Right now our main goal is to get a stable build out that has some fixes/changes necessary for other projects like Drupal and AIR.

Changed February 04, 2008 05:22PM UTC by davidserduke comment:9

Ok I'm going mental I think. Let me try again.

easing: fn && easing || !jQuery.isFunction(easing) && easing

or maybe!

easing: ( fn || !jQuery.isFunction(easing) ) && easing

I'll make sure I actually test the fix before it gets commited. I promise! :)

Changed May 16, 2008 07:56PM UTC by flesler comment:10


So.. do we have a consistent bug or fix ?

Changed November 05, 2008 08:54AM UTC by beat comment:11

the comment above is a spam, to be deleted....

But is now that fixed ?

Changed February 14, 2009 07:52PM UTC by dmethvin comment:12

resolution: → fixed
status: reopenedclosed

Yes, the fix suggested by tgdavies was applied at some point.