Skip to content

Commit

Permalink
updated: use more defensive code #70
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Jan 6, 2020
1 parent 41adb32 commit 5917fc9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Tocca.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@
}
},
getPointerEvent = function(event) {
const hasTargetTouches = Boolean(event.targetTouches && event.targetTouches.length)
switch (true) {
case event.target.touches:
case Boolean(event.target.touches):
return event.target.touches[0]
case event.targetTouches && typeof event.targetTouches[0].pageX !== 'undefined':
case hasTargetTouches && typeof event.targetTouches[0].pageX !== 'undefined':
return event.targetTouches[0]
case event.targetTouches && event.targetTouches[0].touches:
case hasTargetTouches && Boolean(event.targetTouches[0].touches):
return event.targetTouches[0].touches[0]
default:
return event
Expand Down

0 comments on commit 5917fc9

Please sign in to comment.