[英]jQuery Sidescroll, animate ScrollLeft
What is wrong with this? 这有什么问题?
$("body").mousewheel(function(event, delta) {
if(delta>0){
this.animate({scrollLeft: '+=300'},800,'easeOutQuad');
}else if(delta<0){
this.animate({scrollLeft: '-=300'},800,'easeOutQuad');
}
my body width is 8000px
width the mouse wheel function i trigger the function if scroll down and up on mouse wheel. 我的身体宽度是
8000px
鼠标滚轮宽度,如果在鼠标滚轮上上下滚动,则触发该功能。 I want to scroll with the mouse wheel down and the body scroll $(window).width()
to the right site and back... 我想用鼠标滚轮向下滚动,正文将
$(window).width()
滚动到正确的位置并返回...
You need to wrap this
inside event handler into jQuery function: 您需要
this
内部事件处理程序包装到jQuery函数中:
$(this).animate({scrollLeft: '+=300'}, 800, 'easeOutQuad');
because this
is a HTMLBodyElement, it's not a jQuery instance, hence you can't use jQuery methods on it. 因为
this
是HTMLBodyElement,所以它不是jQuery实例,因此不能在其上使用jQuery方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.