Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery slideDown with easing

How can use the slideDown() function with easing?

Maybe extend it somehow?

I'm looking for something like this:

jQuery.fn.slideDown = function(speed, easing, callback) {
  return ...
};

So i can use it slide this

$('.class').slideDown('400','easeInQuad');

or this

$('.class').slideDown('400','easeInQuad',function(){
   //callback
});
like image 893
Sindre Sorhus Avatar asked Nov 04 '09 14:11

Sindre Sorhus


People also ask

How does jQuery slideDown work?

The slideDown() Method in jQuery is used to check the visibility of selected elements or to show the hidden elements. It works on two types of hidden elements: Elements hidden using jQuery methods. Elements hidden using display: none in CSS.

How do you toggle slideUp and slideDown in jQuery?

The slideToggle() method toggles between slideUp() and slideDown() for the selected elements. This method checks the selected elements for visibility. slideDown() is run if an element is hidden. slideUp() is run if an element is visible - This creates a toggle effect.

Which jQuery method is used to slide down an element?

The jQuery slideDown() method is used to slide down an element. Syntax: $(selector).slideDown(speed,callback);

How do you animate a slide in jQuery?

jQuery Animations - The animate() Method The jQuery animate() method is used to create custom animations. Syntax: $(selector).animate({params},speed,callback); The required params parameter defines the CSS properties to be animated.


2 Answers

You can use the animate method with jQueryUI and the easing effects like this:

$(".demo").animate({height: "hide"}, 1500, "easeInQuad", function(){});
like image 161
RedWolves Avatar answered Oct 02 '22 16:10

RedWolves


Take a look at this page, which contains many easing functions: http://gsgd.co.uk/sandbox/jquery/easing/

Using that plugin you can do things like:

$(element).slideUp({
    duration: 1000, 
    easing: method, 
    complete: callback});
like image 37
Seb Avatar answered Oct 02 '22 16:10

Seb