Skip to content

Conversation

@Salman-s10
Copy link

Problem:
On Android, the pinch-to-zoom functionality in the image viewer was zooming from the center instead of the focal point of the pinch. Additionally, when zooming back out, the image would shift abruptly instead of smoothly returning to the center. This caused inconsistent behavior compared to iOS and affected user experience, especially when pinch to zoom on a specific portion of the image.

Solution:

Updated the usePanResponder hook to calculate translation based on the pinch focal point for Android, so zooming happens relative to where the user pinches.

Introduced a threshold (CENTER_THRESHOLD) so the image starts moving toward the center slightly before reaching the initial scale, creating a smooth zoom-out experience.

Ensured that double-tap zoom continues to work correctly by preventing the “snap-to-center” logic from overriding double-tap translations.

Minor cleanup in onRelease to correctly handle tmpScale, tmpTranslate, and currentScale updates.

Impact:

Pinch-to-zoom now works correctly on Android, zooming from the pinch location.

Zoom-out now smoothly centers the image before reaching the initial scale.

Double-tap zoom behavior remains intact and is unaffected by pinch-zoom fixes.

Aligns Android behavior with iOS for a consistent cross-platform experience.

Testing:

Verified pinch-zooming at different focal points.

Verified zoom-out centering behavior.

Verified double-tap zoom on specific portions of the image.

Tested across multiple Android devices to ensure smooth animations.

Problem:
On Android, the pinch-to-zoom functionality in the image viewer was zooming from the center instead of the focal point of the pinch. Additionally, when zooming back out, the image would shift abruptly instead of smoothly returning to the center. This caused inconsistent behavior compared to iOS and affected user experience, especially when pinch to zoom on a specific portion of the image.

Solution:

Updated the usePanResponder hook to calculate translation based on the pinch focal point for Android, so zooming happens relative to where the user pinches.

Introduced a threshold (CENTER_THRESHOLD) so the image starts moving toward the center slightly before reaching the initial scale, creating a smooth zoom-out experience.

Ensured that double-tap zoom continues to work correctly by preventing the “snap-to-center” logic from overriding double-tap translations.

Minor cleanup in onRelease to correctly handle tmpScale, tmpTranslate, and currentScale updates.

Impact:

Pinch-to-zoom now works correctly on Android, zooming from the pinch location.

Zoom-out now smoothly centers the image before reaching the initial scale.

Double-tap zoom behavior remains intact and is unaffected by pinch-zoom fixes.

Aligns Android behavior with iOS for a consistent cross-platform experience.

Testing:

Verified pinch-zooming at different focal points.

Verified zoom-out centering behavior.

Verified double-tap zoom on specific portions of the image.

Tested across multiple Android devices to ensure smooth animations.
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