fix: pointer switch jump on ACTION_POINTER_UP#122
Open
VoidK2 wants to merge 1 commit intopanpf:mainfrom
Open
Conversation
- Add lastPointCount tracking to detect pointer count changes - Reset drag baselines (firstTouch, lastTouch, lastGestureFocus) on transition - Zero out panChange on first frame after pointer count change - Fixes one-frame jump when releasing one finger during pinch zoom Root cause: When ACTION_POINTER_UP switches activePointerId, the first ACTION_MOVE frame uses stale lastTouch coordinates from the two-finger phase, causing a one-frame jump in panChange. Fix: Track lastPointCount and detect transitions. On first frame after pointer count change, reset all drag baselines and zero panChange to prevent the jump.
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.
Summary
Fixes one-frame jump when releasing one finger during pinch zoom.
Problem
When performing a pinch zoom and releasing one finger (pointer transition from 2 to 1), the image center appears to "jump" for one frame. This issue is device-dependent and more visible on certain OEM devices with specific touch sampling rates and motion event batching strategies.
Root Cause
When
ACTION_POINTER_UPswitchesactivePointerId, the firstACTION_MOVEframe uses stalelastTouchcoordinates from the two-finger phase to calculatepanChange, causing a one-frame jump in the pan delta.Solution
lastPointCounttracking to detect pointer count changes (e.g., 2→1 or 1→2)firstTouch,lastTouch,lastGestureFocus)panChangeto prevent the jumpChanges
File modified:
zoomimage-view/src/main/kotlin/com/github/panpf/zoomimage/view/zoom/internal/ScaleDragGestureDetector.ktKey changes:
lastPointCountfield to track pointer count transitionspointCountChangedinACTION_MOVEpanChangeTesting
Related Issues
This is related to the pointer-count transition handling that was previously addressed in issue #12 (fixed in v1.0.1), and later architectural changes in commit
605b4ac1("supports two-finger drag gestures") touched the same detector area.