12

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
});
Sindre Sorhus
  • 62,972
  • 39
  • 168
  • 232

5 Answers5

26

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});
Seb
  • 24,920
  • 5
  • 67
  • 85
14

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

$(".demo").animate({height: "hide"}, 1500, "easeInQuad", function(){});
RedWolves
  • 10,379
  • 12
  • 49
  • 68
4

Easing In and Out:

            $("#SignIn").click(function () {

                $(".divSlideTop").slideDown({
                    duration: 1000,
                    easing: "easeInQuad"
                });
            });

            $("#close").click(function () {

                $(".divSlideTop").slideUp({
                    duration: 1000,
                    easing: "easeOutQuad"
                });
            });
Nalan Madheswaran
  • 10,136
  • 1
  • 57
  • 42
-1
$('.class').slideDown(400,'easeInQuad');

Quotes not need for numeric.

Pang
  • 9,564
  • 146
  • 81
  • 122
gokhan
  • 665
  • 2
  • 9
  • 16
-2

Have a look at my pen Demo you simple to use $(element).slideUp({duration:1000});

shaz3e
  • 316
  • 2
  • 14