Page MenuHomePhabricator

[native] Migrate fling functionality in FullScreenViewModal
ClosedPublic

Authored by angelika on Feb 6 2025, 5:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 16, 12:59 PM
Unknown Object (File)
Tue, Apr 15, 4:08 PM
Unknown Object (File)
Tue, Apr 15, 3:25 PM
Unknown Object (File)
Tue, Apr 15, 1:27 PM
Unknown Object (File)
Tue, Apr 15, 10:37 AM
Unknown Object (File)
Tue, Apr 15, 2:51 AM
Unknown Object (File)
Tue, Apr 15, 1:34 AM
Unknown Object (File)
Mon, Apr 14, 9:02 PM
Subscribers

Details

Summary

https://linear.app/comm/issue/ENG-8150/convert-fullscreenviewmodal-to-reanimated-2-syntax

The fling function is triggered after pan ends. If the image is zoomed in and user moves the image with a pan gesture, the image moves a little with an inertia. Note that there recenter function will run instead if the image is moved to the edge of the screen.

The builds will fail due to some leftover reanimated v1 code. I'll remove it in the next diffs for diffs readability.

Depends on D14307

Test Plan

Tested after migration: there is an inertia effect after pan ended

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

angelika held this revision as a draft.
angelika edited the test plan for this revision. (Show Details)

I'm not sure what the right diff to apply this feedback to is, but I noticed a difference in behavior while testing the changes on my iOS device.

oldnew

Basically, in the old version it seems like the inertia on the x axis is continued despite the "snap back" recentering. In the new version, when the pan concludes it appears that the inertia disappears, and it seems a bit jarring to me.

Note that I performed this testing based on yarn arcpatch D14313, so if that diff hasn't been rebased on the latest changes in an earlier diff, please rebase it and I can try testing again.

This revision is now accepted and ready to land.Feb 17 2025, 3:58 AM

Basically, in the old version it seems like the inertia on the x axis is continued despite the "snap back" recentering. In the new version, when the pan concludes it appears that the inertia disappears, and it seems a bit jarring to me.

Note that I performed this testing based on yarn arcpatch D14313, so if that diff hasn't been rebased on the latest changes in an earlier diff, please rebase it and I can try testing again.

I guess it might be connected with the next diff D14309 where we cancel all the animations when e.g. pan animation is started.

native/components/full-screen-view-modal.react.js
927 ↗(On Diff #47086)

In the old system, it seems like we would run the fling update only if a recenter wasn't occurring. Whereas now, we seem to run the fling update more often: whenever a pan ends that doesn't result in a dismissal.

Currently, the recenter will override the fling update, so it probably works out okay.

928–940 ↗(On Diff #47086)

I have a theory about the issue I shared earlier in the videos:

  1. On panEnd, we set curX and curY here.
  2. Then the useAnimatedReaction in D14307 runs, and it sets curX and curY, resulting in these animations being overriden.

My guess is that the difference with the old system is that the X and Y coordinates were distinct. I think what we see in my "old" video is the X axis being handled by flingUpdate, and the Y axis being handled by recenter.

ashoat requested changes to this revision.Feb 19 2025, 8:36 PM
This revision now requires changes to proceed.Feb 19 2025, 8:36 PM
native/components/full-screen-view-modal.react.js
927 ↗(On Diff #47086)

Yes, in the old system we stop the fling clock if recenter is running. In the new system we override fling update which is kind of the same as stopping the clock.

928–940 ↗(On Diff #47086)

Yes, that's correct. Fixed in https://phab.comm.dev/D14307

Just leaving a note here that we should address this comment in this diff

Just leaving a note here that we should address this comment in this diff

Answering the comment:
I added cancelAnimation(curScale) when dismissing from pan. Now fling should be stopped when activeInteraction is true. In case activeInteraction is triggered by:

  • panActive turning to true: we explicitly cancel all animations in panStart
  • pinchActive turning to true: we explicitly cancel all animation in pinchStart
  • isRunningDismissAnimation: curX and curY are overridden and we explicitly cancel curScale
  • isRunningDoubleTapZoomAnimation: curX, curY and curScale are are overridden

This also applies to the recenter animation.

This revision is now accepted and ready to land.Feb 21 2025, 11:47 PM
This revision was landed with ongoing or failed builds.Feb 25 2025, 2:48 AM
This revision was automatically updated to reflect the committed changes.