diff options
| -rw-r--r-- | go/ui/touchManager.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/go/ui/touchManager.go b/go/ui/touchManager.go index ccc07217..a6bf2ca2 100644 --- a/go/ui/touchManager.go +++ b/go/ui/touchManager.go @@ -112,7 +112,7 @@ func (in *TouchInput) Update() error { // If this one has not been touched long, or moved far, then it's a tap. diff := hypotenuse(t.originX, t.originY, t.currX, t.currY) - if !t.wasPinch && !t.isPan && (t.duration <= LONGTAP_THRESHOLD || diff < 5) { + if !t.wasPinch && !t.isPan && t.duration <= LONGTAP_THRESHOLD && diff < 5 { in.taps = append(in.taps, tap{ x: t.currX, y: t.currY, @@ -150,7 +150,7 @@ func (in *TouchInput) Update() error { t1, t2 := in.touches[id1], in.touches[id2] originDiff := hypotenuse(t1.originX, t1.originY, t2.originX, t2.originY) currDiff := hypotenuse(t1.currX, t1.currY, t2.currX, t2.currY) - if in.pinch == nil && in.pan == nil && math.Abs(originDiff-currDiff) > 3 { + if math.Abs(originDiff-currDiff) > 3 { t1.wasPinch = true t2.wasPinch = true in.pinch = &pinch{ @@ -161,12 +161,12 @@ func (in *TouchInput) Update() error { } } } else if len(in.touches) == 1 { - // Potential pan. + // Potential pan or long tap. id := in.touchIDs[0] t := in.touches[id] - if !t.wasPinch && in.pan == nil && in.pinch == nil { + if !t.wasPinch { diff := math.Abs(hypotenuse(t.originX, t.originY, t.currX, t.currY)) - if diff > 0.25 { + if diff > 0.5 { t.isPan = true in.pan = &pan{ id: id, @@ -175,15 +175,15 @@ func (in *TouchInput) Update() error { prevX: t.originX, prevY: t.originY, } - } - } else if t.duration > LONGTAP_THRESHOLD { - id := in.touchIDs[0] - t := in.touches[id] - t.isLongtap = true - in.longtap = &longtap{ - id: id, - tap: tap{t.originX, t.originY}, - duration: t.duration, + } else if in.longtap == nil && t.duration > LONGTAP_THRESHOLD { + id := in.touchIDs[0] + t := in.touches[id] + t.isLongtap = true + in.longtap = &longtap{ + id: id, + tap: tap{t.originX, t.originY}, + duration: t.duration, + } } } } |
