兼容各大浏览器的触摸滑动(touchmove)事件,说到底还是IE老东家的问题。

var touchStart = "touchstart";
var touchMove = "touchmove";
if (window.navigator.msPointerEnabled) {
touchStart = "MSPointerDown";
touchMove = "MSPointerMove";
}else if (window.navigator.pointerEnabled) {
touchStart = "pointerdown";
touchMove = "pointermove";
}
var me = $("#bar");
me.bind(touchStart, function (e, b) {
if (e.originalEvent.pointerType === "touch" && e.originalEvent.pageY) {
//e.originalEvent.pageY;
} else if (e.originalEvent.touches && e.originalEvent.touches.length) {
//e.originalEvent.touches[0].pageY;
}
});

me.bind(touchMove, function (e) {
if (e.originalEvent.pointerType === "touch" && e.originalEvent.pageY) {
//e.originalEvent.pageY;
} else if (e.originalEvent.touches && e.originalEvent.touches.length) {
//e.originalEvent.touches[0].pageY;
}
});
me.parent().css({
"-ms-touch-action": "pan-y pinch-zoom",
"touch-action": "pan-y pinch-zoom"
}); // 使用 pan-x (垂直划动) 或者 pan-y (水平划动)跟据实际情况而定。

了解更多关于 touch-action Pointer events

Scrolling on the web: A primer