JQuery幻灯片平滑

时间:2013-10-09 12:31:51

标签: javascript jquery

幻灯片动画不流畅,我google了一下,发现我需要为我的容器设置一个固定的宽度,但容器的宽度设置为填充2个其他div。

$('.content_block .content_block_title').on("click", function(event) {
    var target = event.target || event.srcElement;
    var child = $(target).next();

    child.css('width', child.width()); //tried with this but it didnt make the anim smoother.
    if (!child.is(':hidden'))
        child.slideUp(350);
    else
        child.slideDown(150);
});

1 个答案:

答案 0 :(得分:0)

if (!child.is(':hidden'))
        child.animate({    
           height: "350px"
        }, 5000, function() {
           // Animation complete.
        });
    else
        child.animate({    
           height: "150px"
        }, 5000, function() {
          // Animation complete.
        });