Skip to content

feat(core): skip pinch zoom inertia on touch input#10329

Open
charlieforward9 wants to merge 1 commit into
visgl:masterfrom
NEW-HEAT:codex/touch-pinch-inertia-damping
Open

feat(core): skip pinch zoom inertia on touch input#10329
charlieforward9 wants to merge 1 commit into
visgl:masterfrom
NEW-HEAT:codex/touch-pinch-inertia-damping

Conversation

@charlieforward9
Copy link
Copy Markdown
Collaborator

@charlieforward9 charlieforward9 commented May 22, 2026

Why

Pinch-end inertia projects forward by velocity = Δlog2(scale) / Δt × inertia / 2. On touch the final-lift frame is almost always noisy, so even a small synthetic velocity gets multiplied by 300 ms and flings the camera past the gesture. Trackpad / mouse pinches don't suffer the same lift-frame noise.

Change

One guard: when the pinch ended with pointerType === 'touch', take the no-inertia branch unconditionally. Trackpad / mouse pinches keep upstream inertia behavior.

 const {inertia} = this;
 const {_lastPinchEvent} = pinchEventWorkaround;
-if (this.touchZoom && inertia && _lastPinchEvent && event.scale !== _lastPinchEvent.scale) {
+const isTouchPinch = (event.srcEvent as PointerEvent)?.pointerType === 'touch';
+if (
+  this.touchZoom &&
+  inertia &&
+  !isTouchPinch &&
+  _lastPinchEvent &&
+  event.scale !== _lastPinchEvent.scale
+) {

No new constants, no damping math.

Tests

  • MapController skips pinch zoom inertia on touch lift — pinch with a 100× scale spike on the lift frame; asserts the final zoom is the last live zoom, not the projected zoom.

Split out from #10303. Replaces an earlier attempt that capped/halved the projection — guarding on pointerType is both simpler and more correct (real pinches don't fling at all instead of "less far than before").

@coveralls
Copy link
Copy Markdown

coveralls commented May 22, 2026

Coverage Status

coverage: 83.379% (+0.01%) from 83.366% — NEW-HEAT:codex/touch-pinch-inertia-damping into visgl:master

The pinch-end inertia projection is driven by velocity = Δlog2(scale)/Δt
between the last two frames. On touch, the final-lift frame is almost
always noisy, so even a small synthetic velocity gets multiplied by
`inertia` and flings the camera well past where the user expected it
to land.

Gate the inertia branch on `pointerType !== 'touch'`. Trackpad / mouse
pinches keep the existing inertia behavior; touch pinches end at the
last live zoom.

No new constants, no damping math — just one guard.
@charlieforward9 charlieforward9 force-pushed the codex/touch-pinch-inertia-damping branch from 0dd35c6 to 7788e41 Compare May 23, 2026 09:43
@charlieforward9 charlieforward9 changed the title feat(core): tame pinch zoom inertia on touch lift feat(core): skip pinch zoom inertia on touch input May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants