Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How might I fade + slide an element in?

I want to slide + fade an element in, when I try doing

$("ul", this).fadeIn(300).slideDown(600);

I just get the fadeIn, how can I fade while slide an element in?

like image 938
Jiew Meng Avatar asked Dec 16 '22 16:12

Jiew Meng


2 Answers

You can use animation for this

$("ul").animate({
"height": "toggle", "opacity": "toggle" 
}, "slow");
like image 52
lc0 Avatar answered Jan 05 '23 21:01

lc0


this will slide down then fade in

insert this function somewheres

jQuery.fn.doubleHide = function(){
    return $(this).hide().css('opacity', '0');
}


jQuery.fn.slideFade = function(slide, fade){
return $(this).slideDown(slide, function () {
    $(this).fadeTo(fade, 100);
    });
}

then u can call this function like the fadeIn()

        $(this).stop(true).doubleHide().slideFade(400, 2000);
like image 42
Ruttyj Avatar answered Jan 05 '23 23:01

Ruttyj