Skip to content

Commit

Permalink
Merge pull request #19 from retejs/fix/translation-in-macos
Browse files Browse the repository at this point in the history
Fix/translation in macos
  • Loading branch information
Ni55aN authored Apr 1, 2024
2 parents dd419a3 + 900d054 commit 0999d20
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/zoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class Zoom {

window.addEventListener('pointermove', this.move)
window.addEventListener('pointerup', this.up)
window.addEventListener('contextmenu', this.contextmenu)
window.addEventListener('pointercancel', this.up)
}

Expand Down Expand Up @@ -68,7 +69,7 @@ export class Zoom {
const { left, top } = this.element.getBoundingClientRect()
const { cx, cy, distance } = this.getTouches()

if (this.previous !== null) {
if (this.previous !== null && this.previous.distance > 0) {
const delta = distance / this.previous.distance - 1

const ox = (left - cx) * delta
Expand All @@ -79,6 +80,10 @@ export class Zoom {
this.previous = { cx, cy, distance }
}

protected contextmenu = () => {
this.pointers = []
}

protected up = (e: PointerEvent) => {
this.previous = null
this.pointers = this.pointers.filter(p => p.pointerId !== e.pointerId)
Expand Down

0 comments on commit 0999d20

Please sign in to comment.