views:

248

answers:

1

I would like to add a subtle and quick fadeOut and FadeIn effect to a button change through switchClass.

jQuery("a#btnPause").switchClass(pauseClass,playClass,200);

The effect used by default is a slideLeft.

If I would use standard jQuery, I would like to put an effect on addClass and removeClass, but is that possible?

A: 

Is something like

$("a#btnPause").fadeOut(200).switchClass(pauseClass,playClass,200).fadeIn(200);

what you're looking for?

Matt Ball
ah, can you just chain up the effects, that's nice. the a#btnPause is a button, I think it will not be good to have it dissapear, since then the other buttons (which are also there) would move. Still I think your solution is great when I fadeout to opacity 0.01.thanks!
PlanetMaster
I don't think fadeOut will cause the surrounding elements to shift because it's only setting the opacity to zero - it's not actually hiding the element (via `display: hide`). Is this correct?
Matt Ball
I thought a fadeout ends with a display:noneI'm gonna do some tests :)
PlanetMaster
You're entirely right! I missed that in the docs the first time through. Sorry! On the other hand, you can still fadeTo 0 (rather than 0.01) which won't hide the element.
Matt Ball