Skip to content

fix: pointer switch jump on ACTION_POINTER_UP#122

Open
VoidK2 wants to merge 1 commit intopanpf:mainfrom
VoidK2:fix/pointer-switch-jump
Open

fix: pointer switch jump on ACTION_POINTER_UP#122
VoidK2 wants to merge 1 commit intopanpf:mainfrom
VoidK2:fix/pointer-switch-jump

Conversation

@VoidK2
Copy link
Copy Markdown

@VoidK2 VoidK2 commented Apr 7, 2026

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_UP switches activePointerId, the first ACTION_MOVE frame uses stale lastTouch coordinates from the two-finger phase to calculate panChange, causing a one-frame jump in the pan delta.

Solution

  • Added lastPointCount tracking to detect pointer count changes (e.g., 2→1 or 1→2)
  • On first frame after pointer count change:
    • Reset drag baselines (firstTouch, lastTouch, lastGestureFocus)
    • Zero out panChange to prevent the jump
  • This ensures clean state transition between single-finger and multi-finger gesture phases

Changes

File modified: zoomimage-view/src/main/kotlin/com/github/panpf/zoomimage/view/zoom/internal/ScaleDragGestureDetector.kt

Key changes:

  1. Added lastPointCount field to track pointer count transitions
  2. Detect pointCountChanged in ACTION_MOVE
  3. On transition: reset baselines and zero panChange

Testing

  • ✅ Two-finger zoom → release one finger while still moving
  • ✅ One-finger drag → add second finger to zoom
  • ✅ Zoom past bounds → release → rollback center check
  • ✅ No regression in fling/rollback behavior
  • ✅ ViewPager interception behavior unchanged

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.

- 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.
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.

1 participant