0

I've got this jQuery rule to set .preloader to display none

$(".preloader").css("display", "none");

I How ever I want it to disappear with fade out effect and also while it's fading zoom out, I don't know how to do zoom out effect, but I tried applying this to make it fade out

$(".preloader").css("display", "none").fadeOut("200");

How ever that didn't work. Can you please suggest how to achieve those two effects? Also, will solution work vice versa? (fade it in, and zoom it in until it's original sizes)

1
  • 1
    you cannot fade a display none, fade out simply changes the opacity levels Commented Apr 10, 2013 at 21:06

7 Answers 7

3

In order to fade it out, just use fadeOut(). The end of the animation is actually setting a display: none to the element:

$(".preloader").fadeOut("200");
Sign up to request clarification or add additional context in comments.

Comments

2

$(".preloader").toggle('hide'); and $(".preloader").toggle('show'); should do it, but $.toggle() by itself works if you don't care what the display state is.

However,

$(".preloader").stop(true,false).animate({
    width: 'toggle',
    height: 'toggle',
    opacity: 'toggle'
});

is way cooler, and you only need one statement. You could use a boolean with $.toggle(yourShowStateBooleanVariableGoesHere), too.

Also, I recommend you use id rather than class selectors unless it absolutely has to be applied to all classes (which I find rare).

2 Comments

cool, what could be opposite of toggle? so to display things?
@IlyaKnaup you should be hooked up to go both directions now. toggle and the animation is the only way to get the "zoom". if you want "real" zoom, let me know, and I'll do css3 for you
2
$(".preloader").css("display", "none").fadeOut("200");

this code first hides the .preloader and than tries to fadeOut wich is impossable because its already hidden.

try this:

$(".preloader").fadeOut(200);

or

$(".preloader").fadeOut("fast");

Comments

0
$(".preloader").hide().fadeIn("200");

$(".preloader").fadeOut("200");

2 Comments

Not to my knowledge. See the jquery docs for hide() and show(). They work instantly, unless given a time as parameter. They also have a callback function. api.jquery.com/hide
Definitely. The docs don't say it would work at all, but for some reason I remember having done something like that and it worked... My memory's getting bad I guess :-)
0

When the fadeOut effect completes it sets the display to none for you, so you dont need the css method.

Comments

0
$(document).ready(function(){
    $(".preloader").hover(function(){
        $(".preloader").fadeOut();
    }, function(){
         $(".preloader").fadeIn();   
    });
});

http://jsfiddle.net/BY3tz/8/

This should give you some hints.

Comments

0

If you also want a zoom out, this could be a possible sollution:

$('.preloader').animate({width: 'toggle', height: 'toggle', opacity: 'toggle'}, 1000); 

Use the same to get it back.

Have a look at the fiddle.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.