Skip to content

Commit c516011

Browse files
authored
fix: allow other actions during trackpad pinch (#625)
1 parent 5c7c43f commit c516011

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/CameraControls.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,8 @@ export class CameraControls extends EventDispatcher {
771771
const x = this.dollyToCursor ? ( event.clientX - this._elementRect.x ) / this._elementRect.width * 2 - 1 : 0;
772772
const y = this.dollyToCursor ? ( event.clientY - this._elementRect.y ) / this._elementRect.height * - 2 + 1 : 0;
773773

774-
// event.ctrlKey is set to true on macOS trackpad pinch gesture. In this case, always zoom.
775-
const controlMode = event.ctrlKey ? ACTION.ZOOM : this.mouseButtons.wheel;
774+
// event.ctrlKey is set to true on macOS during a trackpad pinch gesture. In this case, treat it as a two-finger pinch gesture, but not a two-finger move.
775+
const controlMode = ! event.ctrlKey ? this.mouseButtons.wheel : this.touches.two;
776776
switch ( controlMode ) {
777777

778778
case ACTION.ROTATE: {
@@ -807,15 +807,23 @@ export class CameraControls extends EventDispatcher {
807807

808808
}
809809

810-
case ACTION.DOLLY: {
810+
case ACTION.DOLLY:
811+
case ACTION.TOUCH_DOLLY:
812+
case ACTION.TOUCH_DOLLY_ROTATE:
813+
case ACTION.TOUCH_DOLLY_TRUCK:
814+
case ACTION.TOUCH_DOLLY_OFFSET: {
811815

812816
this._dollyInternal( - delta, x, y );
813817
this._isUserControllingDolly = true;
814818
break;
815819

816820
}
817821

818-
case ACTION.ZOOM: {
822+
case ACTION.ZOOM:
823+
case ACTION.TOUCH_ZOOM:
824+
case ACTION.TOUCH_ZOOM_ROTATE:
825+
case ACTION.TOUCH_ZOOM_TRUCK:
826+
case ACTION.TOUCH_ZOOM_OFFSET: {
819827

820828
this._zoomInternal( - delta, x, y );
821829
this._isUserControllingZoom = true;

0 commit comments

Comments
 (0)