From 849f20e5905aee8a156fc26299f98360b5c496ed Mon Sep 17 00:00:00 2001 From: Ni55aN Date: Mon, 1 Apr 2024 23:21:48 +0300 Subject: [PATCH 1/2] fix(zoom): translation in mac os force pointers reset on context menu --- src/zoom.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/zoom.ts b/src/zoom.ts index be4e383..9aab38d 100644 --- a/src/zoom.ts +++ b/src/zoom.ts @@ -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) } @@ -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) From 900d05419fa3a6a0223b67af707ad7af30c3c1ed Mon Sep 17 00:00:00 2001 From: Ni55aN Date: Mon, 1 Apr 2024 23:22:29 +0300 Subject: [PATCH 2/2] fix(zoom): translation with equal pointers position --- src/zoom.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zoom.ts b/src/zoom.ts index 9aab38d..622fe7e 100644 --- a/src/zoom.ts +++ b/src/zoom.ts @@ -69,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