[英]jQuery and scroll animation conflict
My function works 100% when i only scroll a little bit, but when i scroll all the page down and scroll up fast, my opacity:0 take longer or doesn't work at all. 当我只滚动一点时,我的功能可以工作100%,但是当我向下滚动所有页面并快速向上滚动时,我的opacity:0需要更长的时间或根本不起作用。 Have any idea why ?
有什么想法吗? It is because my function i call to many times ?
是因为我多次调用我的函数吗?
$(window).scroll(function () {
var TopValue = $(window).scrollTop();
if (TopValue <= 50) {
$("div.mouseover > p").css('opacity', 0);
} else {
$("div.mouseover > p").animate({
opacity: '1.0'
}, 1000);
}
});
Since your function
call is happening multiple times, You have to clear the animation queue
before starting another animation
, Please read .stop() for further clarifications. 由于您的
function
调用发生了多次,因此您必须在开始另一个animation
之前清除animation queue
,请阅读.stop()以获取进一步的说明。
Try this, 尝试这个,
$(window).scroll(function () {
var TopValue = $(window).scrollTop();
if (TopValue <= 50) {
$("div.mouseover > p").css('opacity', 0);
} else {
$("div.mouseover > p").stop().animate({
opacity: '1.0'
}, 1000);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.