Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#9223 closed bug (worksforme)

Child elements do not animate correctly when using animateClass (addClass, removeClass, toggleClass, switchClass)

Reported by: BenEllis Owned by:
Priority: minor Milestone: none
Component: ui.effects.core Version: 1.10.1
Keywords: Cc:
Blocked by: Blocking:


reproduced in IE9, Firefox 19.02, Chrome 26.0.1410.64 m in 64-bit Windows 7 Enterprise

Child elements are not being animated when using the animatedClass feature. e.g.

addClass('myclass', 500);
removeClass('myclass', 500);
toggleClass('myclass', 500);
switchClass('myclass', 500);

I believe this is down to this line of code in jquery-ui-1.10.1,

allAnimations = o.children ? animated.find( "*" ).addBack() : animated;

o.children is always undefined as it is the return value from the $.speed call, I believe this should probably be,

allAnimations = animated.children().length > 0 ? animated.find("*").addBack() : animated;

however, the animation can be slow for elements with a large number of children.

The best fix would be to probably identify which elements would be affected by adding the class to the root element and only animating those elements.

A quick fix is to add a childSelector argument to only animate those children defined by the calling client code, this is a bit of a smell but is probably the best solution for performance.

Change History (4)

comment:1 Changed 9 years ago by BenEllis

I have a patch for this which I will submit shortly.

comment:2 Changed 9 years ago by BenEllis

My sample was incorrect, please use instead.

comment:3 Changed 9 years ago by Scott González

Resolution: worksforme
Status: newclosed

The code is correct. You need to pass an options hash to use the children option:

See for the documentation issue.

comment:4 Changed 9 years ago by BenEllis

The performance of this seems quite slow when there are many children, I raise a separate ticket (#9226) to address performance by adding a filter parameter or calculating which children are affected by the CSS class.

Note: See TracTickets for help on using tickets.