-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable attachment carousel scroll when zoomed in #18634
Disable attachment carousel scroll when zoomed in #18634
Conversation
@tylerkaraszewski Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@@ -198,12 +201,15 @@ class ImageView extends PureComponent { | |||
scale: 2, | |||
duration: 100, | |||
}); | |||
|
|||
this.props.onScaleChanged(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onMove
will be called after the zoom animation, so it's possible to zoom and swipe and stuck in between the images. Sending scale just when we actually trigger the animation makes this nearly impossible, you should be really fast to catch in between state updates. And this lucky case will be fixed by migration to UI thread only code with gesture handler and reanimated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like your explanation, please add comment in code why this manual call is needed
@terrysahaidak please fix conflict came from prettier |
@aimane-chnaif thanks a lot. this implementation was discussed basically here in this thread on Slack: https://expensify.slack.com/archives/C035J5C9FAP/p1682027016020719 The current plan we agreed on is to merge the fix to unblock the zoom feature for the users and work on a better implementation altogether. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to make sense to me.
@aimane-chnaif bump. |
I will review this tomorrow |
@aimane-chnaif bump! |
Now that App/src/components/AttachmentView.js Lines 40 to 41 in cb4f7c9
|
When double tap, sometimes zoom doesn't work because of Pressable onPress event. ios-bug.mov |
@aimane-chnaif the bug you described is not related to the changes in this PR and is related to the image-zoom library. PDF uses a different zoom implementation this is why it doesn't happen there. |
@puneetlath mind considering this out of scope here? |
If it exists on main then I think it's fine to consider that out of scope here. |
@terrysahaidak please complete checklist |
Any update? |
Reviewer Checklist
Screenshots/VideosWebweb.moviOSios.movAndroidandroid.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good!
Just waiting for author checklist to be completed
hey, sorry for the delay, I saw in another merged PR where it also was changing something for iOS/android only and they did not check other platforms since there were no changes and provided screen recordings. I checked everything. I'll add the comment in the code as requested in ~2h. |
@aimane-chnaif should be good to go! |
@terrysahaidak you have a lint issue. |
Edited code using github.dev and as always there are some random eslint/prettier errors :( |
Oh, I've never used it. How could we get prettier working in there? |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/puneetlath in version: 1.3.24-0 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.24-5 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.24-5 🚀
|
Details
There are many problems with the current image zoom component. First of all, it's deprecated by the authors. There are workarounds for double ckick for zoom, it doesn't zoom when you pinch until you double press etc, but also it uses PanResponder and runs all the logic on the JS thread, so when JS thread is blocked by something it doesn't respond to gestures.
And there was another bug - if you zoom in, the pager's scroll view would scroll alongside the pan responder.
Since the whole component is deprecated and we already have quite a few workarounds I decided to just block the scroll completely when you zoom in, since on iOS it doesn't work properly, on Android it sometimes might work, but there is no clear UX pattern when it works.
There is no easy way to fix this properly so it works on both platforms well.
I already tried:
scrollEnabled
usingreact-native-reanimated
'suseAnimatedProps
, but it still doesn't allow for the proper swipe to the left/right to change the pagereact-native-gesture-handler
and scroll view where we would block the gesture until weenable
it on the UI thread, but it requires the zoom component to be written with reanimated and gesture handler as well, but also this same behavior doesn't properly work on Android, i might require some fixes in the gesture handler codeSo in order to properly fix this component for good, we need to rewrite it with gesture-handler and reanimated, so all the logic is running on UI thread, then we can combine gesture-handlers for single tap, double tap, pan and pinch gestures in order to enable rich UX for the image zoom.
But in the meantime this change allows users to actually use the app with a slight inconvenience - they have to zoom out to navigate to the next page.
Fixed Issues
$ #17720
PROPOSAL: GH_LINK_ISSUE(COMMENT)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
No changes
Mobile Web - Chrome
No changes
Mobile Web - Safari
No changes
Desktop
No changes
iOS
RPReplay_Final1683628727.mov
Android
telegram-cloud-document-2-5391220435167750468.mp4