最近在做横滚事件,不过用滚轴事件,不过为什么滚动事件会是连续的,求教 $("body").mousewheel(function(event, delta, deltaX, deltaY){
var pagepostion =$("#pagepostion").val();
var waplist=$(".brand_main").length;
var _h;
var marginLeft = (screenWidth - 1000)/2;
if(delta<0){
if(pagepostion>=0){
if(pagepostion==waplist-1){
return;
}
pagepostion++;
$("#pagepostion").val(pagepostion);
}
_h="#b"+$("#pagepostion").val();
$("html,body").animate({ 'scrollLeft' : $(_h).offset().left - marginLeft },1000,"circEaseOut",function(){
return false;
});
}else{
if(pagepostion<=waplist-1){
if(pagepostion==0){
return;
}
pagepostion--;
$("#pagepostion").val(pagepostion);
}
_h="#b"+$("#pagepostion").val();
$("html,body").animate({ 'scrollLeft' : $(_h).offset().left - marginLeft },1000,"circEaseOut",function(){
return false;
});
}
event.stopPropagation();
event.preventDefault();
return false;
});jQuery
var pagepostion =$("#pagepostion").val();
var waplist=$(".brand_main").length;
var _h;
var marginLeft = (screenWidth - 1000)/2;
if(delta<0){
if(pagepostion>=0){
if(pagepostion==waplist-1){
return;
}
pagepostion++;
$("#pagepostion").val(pagepostion);
}
_h="#b"+$("#pagepostion").val();
$("html,body").animate({ 'scrollLeft' : $(_h).offset().left - marginLeft },1000,"circEaseOut",function(){
return false;
});
}else{
if(pagepostion<=waplist-1){
if(pagepostion==0){
return;
}
pagepostion--;
$("#pagepostion").val(pagepostion);
}
_h="#b"+$("#pagepostion").val();
$("html,body").animate({ 'scrollLeft' : $(_h).offset().left - marginLeft },1000,"circEaseOut",function(){
return false;
});
}
event.stopPropagation();
event.preventDefault();
return false;
});jQuery
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货