jquery制作移動端菜單欄左右滑動


//菜單欄滑動
function move_scollX(){
var startPosition, endPosition, distanceX,distanceY;
$(".left").bind('touchstart', function(e){ 
  var touch = e.originalEvent.changedTouches[0]; //移動端
  startPosition = {
    x: touch.pageX,
    y:touch.pageY
  }
}) .bind('touchmove', function(e){

  var touch = e.originalEvent.changedTouches[0]; //移動端
  endPosition = {
    x: touch.pageX,

    y:touch.pageY

}; 

distanceX = endPosition.x - startPosition.x;

distanceY = endPosition.Y - startPosition.Y; 
if(distanceX < 0) { // 向左移動
  $(this).css({"left":distanceX});
} else if (distanceX > 0) { // 向右移動
  $(this).css({"left":distance});
}
}
}
}).bind('touchend', function(e){ //放開事件
  $(this).animate({"left":-width},100);
}
});
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM