Answers for "javascript touch scroll event"

0

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
})
Posted by: Guest on May-25-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language