javascript touch scroll event code example
Example: javascript touch scroll event
var lastTouch = null
window.addEventListener('touchstart', function (event) {
lastTouch = event.touches[0]
})
window.addEventListener('touchend', function (event) {
lastTouch = null
})
window.addEventListener('touchmove', function (event) {
var currentTouch = event.changedTouches[0]
if (lastTouch) {
target.scrollTop += currentTouch.clientY - lastTouch.clientY
}
lastTouch = currentTouch
})