views:

196

answers:

3

I want to use the jQuery show(700) function, but I do not want any opacity changes. The element in question has a background PNG image with alpha transparency, and the opacity change causes strange black borders around the background image during the animation. How can I omit opactiy animation from the show() function?

+1  A: 

I just found it. Search for the genFx function in jQuery. You see it loops through arrays of styles and returns an object of the right styles, which eventually gets passed to the animate function internally. Just remove "opacity" from the array!

This also might work for you...

.animate({ width: "show" });
Josh Stodola
+3  A: 

Use the animate function and simply vary the width and height. Here's a plugin that will do a reveal.

jQuery.fn.extend( {
    reveal: function() {
       return this.each( function() {
           var $this = $(this);
           $this.animate( { width: "show", height: "show" } );
       });
    }
}
tvanfosson
Thanks a lot, Tim!!
Josh Stodola
A: 

jQuery's show slowly (show with a duration) does a slidedown and a fadein simultaneously. If all you want is the slidedown, just use the slidedown.

jQuery("#someElement").slideDown(700);

Not much more to say about that.

darkporter
I think the function name needs to be camelCase.
Jacob Relkin
Also, it doesn't just slide-down and fade-in, it also expands the width.
J-P
Yeah, camel case, I updated my answer. And I forgot that show(milliseconds) does a fadein, a slidedown _and_ and slide "out". In that case @tvanfosson's answer looks best.
darkporter
`slideDown` only animates the height, I primarily would like to animate the width. My answer is working, and so is tvanfosson's. Thanks for the help.
Josh Stodola