From f58eee272f5ebe119746fbb201b47292598f2e94 Mon Sep 17 00:00:00 2001 From: Gianmarco Date: Thu, 12 Oct 2023 18:04:58 +0200 Subject: [PATCH] fix: revert use of setPointerCapture (#305) --- src/controls/OrbitControls.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/controls/OrbitControls.ts b/src/controls/OrbitControls.ts index e44acb3b..a4d73372 100644 --- a/src/controls/OrbitControls.ts +++ b/src/controls/OrbitControls.ts @@ -414,8 +414,8 @@ class OrbitControls extends EventDispatcher { scope.domElement?.removeEventListener('pointerdown', onPointerDown) scope.domElement?.removeEventListener('pointercancel', onPointerCancel) scope.domElement?.removeEventListener('wheel', onMouseWheel) - scope.domElement?.removeEventListener('pointermove', onPointerMove) - scope.domElement?.removeEventListener('pointerup', onPointerUp) + scope.domElement?.ownerDocument.removeEventListener('pointermove', onPointerMove) + scope.domElement?.ownerDocument.removeEventListener('pointerup', onPointerUp) if (scope._domElementKeyEvents !== null) { scope._domElementKeyEvents.removeEventListener('keydown', onKeyDown) } @@ -812,10 +812,8 @@ class OrbitControls extends EventDispatcher { if (scope.enabled === false) return if (pointers.length === 0) { - scope.domElement?.setPointerCapture(event.pointerId) - - scope.domElement?.addEventListener('pointermove', onPointerMove) - scope.domElement?.addEventListener('pointerup', onPointerUp) + scope.domElement?.ownerDocument.addEventListener('pointermove', onPointerMove) + scope.domElement?.ownerDocument.addEventListener('pointerup', onPointerUp) } addPointer(event) @@ -843,8 +841,8 @@ class OrbitControls extends EventDispatcher { if (pointers.length === 0) { scope.domElement?.releasePointerCapture(event.pointerId) - scope.domElement?.removeEventListener('pointermove', onPointerMove) - scope.domElement?.removeEventListener('pointerup', onPointerUp) + scope.domElement?.ownerDocument.removeEventListener('pointermove', onPointerMove) + scope.domElement?.ownerDocument.removeEventListener('pointerup', onPointerUp) } scope.dispatchEvent(endEvent)