feat(core): skip pinch zoom inertia on touch input#10329
Open
charlieforward9 wants to merge 1 commit into
Open
feat(core): skip pinch zoom inertia on touch input#10329charlieforward9 wants to merge 1 commit into
charlieforward9 wants to merge 1 commit into
Conversation
4567349 to
0dd35c6
Compare
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.
0dd35c6 to
7788e41
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
pointerTypeis both simpler and more correct (real pinches don't fling at all instead of "less far than before").