Skip to content

[Lightbox] Fix jump when zooming out on iOS#6633

Merged
gaearon merged 1 commit into
mainfrom
fix-ios-bounce
Nov 22, 2024
Merged

[Lightbox] Fix jump when zooming out on iOS#6633
gaearon merged 1 commit into
mainfrom
fix-ios-bounce

Conversation

@gaearon
Copy link
Copy Markdown
Contributor

@gaearon gaearon commented Nov 22, 2024

Currently, we disable bounce when the image is 1:1. This is to allow it being swiped away (instead of bouncing). However, this actually introduces a problem: if you start pinching in first, and then pinch out, the image will jump as you cross the 1:1 threshold. That's because the bounces prop would change while dragging, and disabling bouncing would force-center the image. The fix is to only disable bouncing while both 1:1 and at rest.

Implementation-wise, I wanted an excuse to try useAnimatedProps, so this is it. Seems like a convenient way to toggle native props without leaving the UI thread. An alternative would be to call setNativeProps imperatively.

Test Plan

Verify you still can swipe away images when at rest.

Verify you still cannot swipe away images while zoomed in.

Verify that if you pinch in and out (and in and out again), crossing the 1:1 threshold does not cause visual jumps. This is much easier to test on the device; if you do it on the Simulator, you'll have to both pinch and pan to reproduce the jump.

Before

before.mov

After

after.mov

@arcalinea arcalinea temporarily deployed to fix-ios-bounce - social-app PR #6633 November 22, 2024 12:46 — with Render Destroyed
@github-actions
Copy link
Copy Markdown
Contributor

Old size New size Diff
8.06 MB 8.06 MB 0 B (0.00%)

Copy link
Copy Markdown
Member

@mozzius mozzius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, seems better

@gaearon gaearon merged commit a0acd51 into main Nov 22, 2024
@gaearon gaearon deleted the fix-ios-bounce branch November 22, 2024 13:41
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.

3 participants