简体   繁体   English

jQuery的动画隐藏滚动

[英]jquery animate hide the scroll

i have a little issue animeting a div that is overflowed , the scroll blink during animation. 我有一个小问题,动画一个overfloweddiv ,动画期间滚动闪烁。

i made a fast example: 我做了一个快速的例子:

$(".div-animate").on("click", function(e){
    var toTop = 100,
        toHeight = $(this).outerWidth(true) + toTop;

    $(this).animate({
        top: toTop,
        height: toHeight
    });
});

live example 实例

how can i prevent this little 'scroll blink' ? 我怎么能防止这个小小的'滚动眨眼'?

jQuery adds an overflow:hidden rule when use animate function. jQuery在使用animate函数时添加了overflow:hidden规则。 There are two hacks you can do: 您可以执行两种操作:

1) Modify the line of the jQuery source where overflow is setted to hidden (you can do this only if you import jquery from your site) 1)修改jQuery源代码行,其中将溢出设置为隐藏(仅当您从网站导入jquery时才能执行此操作)

2) Force the property in your css doing something like this 2)强制你的css中的属性做这样的事情

.div-animate {
     overflow: auto !important;
}

Well this can be done this way too: 那么这也可以这样做:

$(this).animate({
        top: toTop,
        height: toHeight
    }).css({"overflow":"auto"});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM