开发者

JQuery slideup and slidedown is not smooth enough

I am implementing a slide dropdown and i am using this code

$(document).ready(function(){
    $('.drop').click(function(){
        var $next = $(this).parent().next('li.drop_down');
        if($next.is(':v开发者_Go百科isible')) {
            $next.slideUp();
        } else {
            $next.slideDown();
        }
    });
});

but the client claims that it is not smooth enough. He wants to expand really smooth, so is there a way to make it smoother


You might want to incorporate the easing plugin for smoother animation.


If your animation is not smooth you need to give the element that gets slidedUp/slidedDown a width in pixel (not in percent!), this helps me most of the time.


I just came across your question and I have the same problem. For men what fixed it is to remove padding. I don't know but for some reason it is not taken into account as a total of the element's height.


according to all answers and my experience:

  1. don't use min-height.
  2. don't use padding (set padding for inside of container is ok).
  3. don't use width in percent.

p.s. 1: you can use responsive width (in percent), but you have remove padding (set internal container element padding).

p.s. 2: you can use fixed width and padding together, sometimes its work properly.


You could try the jQuery UI library. The Event() class provides a Slide effect where you can adjust speed and other presentation-related attributes

http://jqueryui.com/demos/effect/


You can incrase the animation duration by adding a number of ms inside the slideUp/slideDown()'s:

    if($next.is(':visible')) {
        $next.slideUp(2500);
    } else {
        $next.slideDown(2500);
    }

That should get all the smoothness you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜