JQuery 1.5.0 and animating backgroundPosition

I wasted a lot of time tonight trying to debug this annoying problem. I recently upgraded from loading JQuery 1.4.4 to 1.5.0 with Google CDN. When I upgraded, my backgroundPosition animations stopped functioning.

For example, I used to have:

$(this).stop().animate({backgroundPosition: ['-1800px 0px', 'easeOutExpo']},5000);

This no longer works in version 1.5.0 loaded from Google CDN. Let it be noted that I am using JQuery UI 1.8.9, also loaded from Google CDN. I’m guessing that the problem is the fault of JQuery, rather than Google’s hosting of the code.

For now, I’m taking the advice I got on Stack Overflow and sticking with JQuery 1.4.4 until this gets fixed.

The joys of coding.

Update: Actually, this might not be a bug, but rather the intended functionality. Apparently the fact that it worked in 1.4.4 at all is a coincidence, as according to the JQuery API: “All animated properties should be animated to a single numeric value, except as noted below; most properties that are non-numeric cannot be animated using basic jQuery functionality. (For example, width, height, or left can be animated but background-color cannot be.)” Since backgroundPosition requires two numeric values, it should not be supported.

See this bug ticket.

And a possible solution..

2 comments

Leave a comment

Your email address will not be published. Required fields are marked *