//判断是否手机端
var isMobile = false;
try {
//手机端
document.createEvent("TouchEvent");
isMobile = true;
} catch (e) {
//pc
}
//手势事件
var startX = 0, endX = 0, move_left = null;
//按下时触发
$(‘元素‘).on(‘touchstart‘, function (e) {
e.preventDefault()
var touch = event.touches[0];
startX = touch.pageX;
})
//移动时触发
$(‘元素‘).on(‘touchmove‘, function (e) {
var touch2 = event.touches[0];
endX = touch2.pageX;
})
//离开时触发
$(‘元素‘).on(‘touchend‘, function (e) {
time = setInterval(picTimer, opts.Time)
if (!scrollList.is(":animated")) {
e.preventDefault()
if (startX > endX) {
index += 1;
if (index == len) { index = 0; }
showPics(index);
} else {
index -= 1;
if (index == -1) { index = len - 1; }
showPics(index);
}
}
}
不会到会,只是一个过程!
时间: 2024-10-11 08:45:21