Skip to content

Commit

Permalink
explicit check number of touches before scale and move
Browse files Browse the repository at this point in the history
  • Loading branch information
thurti committed Aug 13, 2021
1 parent e22cb50 commit e7124eb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
function onTouchStart(e) {
touchScreen = true
const isSingleTouch = e.touches.length === 1
const isMultiTouch = e.touches.length === 2
const [touchA, touchB] = e.touches
Expand All @@ -275,7 +276,7 @@
fireScale(touchA, touchB)
velocity.down(touchA, touchB)
} else {
} else if (isSingleTouch) {
const { pageX, pageY } = touchA
var now = new Date().getTime()
if (now - lastTap.time < 250 && Math.hypot(lastTap.current.x - pageX, lastTap.current.y - pageY) <= 20) {
Expand All @@ -299,10 +300,13 @@
}
function onTouchMove(e) {
if (scale.scaling) {
const isSingleTouch = e.touches.length === 1
const isMultiTouch = e.touches.length === 2
if (scale.scaling && isMultiTouch) {
const [touchA, touchB] = e.touches
fireScaleMove(touchA, touchB)
} else {
} else if (isSingleTouch) {
fireMove(e.touches[0].pageX, e.touches[0].pageY)
}
}
Expand Down

0 comments on commit e7124eb

Please sign in to comment.