I have tried to get: var startX = 0, startY = 0;
on the Internet. function touchStart(e) {
var touch = e.touches[0],
x = Number(touch.pageX),
y = Number(touch.pageY);
startX = x;
startY = y;
}
document.addEventListener("touchstart", touchStart);
var ele = document.querySelector(".scroll");
ele.ontouchmove= function (e) {
var point = e.touches[0],
eleTop = ele.scrollTop,
eleScrollHeight = ele.scrollHeight,
eleOffsetHeight = ele.offsetHeight,
eleTouchBottom = eleScrollHeight - eleOffsetHeight;
if (eleTop === 0) {
if (point.clientY > startY) {
e.preventDefault();
}
}
else if (eleTop == eleTouchBottom) {
if (point.clientY < startY) {
e.preventDefault();
}
}
}
however, there is a scroll bar event in the page, but the drop-down does not work;