Page MenuHomePhabricator

[native] Migrate backdropOpacityUpdate in FullScreenViewModal
ClosedPublic

Authored by angelika on Feb 6 2025, 5:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 9, 5:46 PM
Unknown Object (File)
Wed, Mar 26, 4:21 PM
Unknown Object (File)
Wed, Mar 26, 11:34 AM
Unknown Object (File)
Tue, Mar 25, 6:23 AM
Unknown Object (File)
Mon, Mar 17, 11:52 AM
Unknown Object (File)
Mon, Mar 17, 11:41 AM
Unknown Object (File)
Mon, Mar 17, 10:54 AM
Unknown Object (File)
Sun, Mar 16, 3:15 PM
Subscribers

Details

Summary

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

Migrate backdropOpacityUpdate function. In this function there are a couple of things mixed together going on:

  • depending on the current position of the image calculate backdrop opacity (progressiveOpacity) variable to give a hint to the user that you're closing the modal - the farer the image from the center the more transparent the backdrop
  • if pinch gesture is active or the image is zoomed in then ignore the above and run animation with timing on backdrop opacity to opacity = 1
  • if we move fast / far enough (shouldGoBack) animate image position with decay (so the image moves with inertia) and close the modal

Also I needed some minor things like migrating close method and adding withDecay method to reanimated types.

Depends on D14305

Test Plan

Tested after migration:

  • verify the background opacity is animated on pan
  • verify the modal is closed if panned fast/far enough when zoomed out

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 summary of this revision. (Show Details)
tomek added inline comments.
native/flow-typed/npm/react-native-reanimated_v2.x.x.js
597–604 ↗(On Diff #47084)

Should this be exact?

This revision is now accepted and ready to land.Feb 17 2025, 3:47 AM
native/components/full-screen-view-modal.react.js
355 ↗(On Diff #47084)

In the old system, dismissingFromPan was taken into account in activeInteraction, which would prevent recenter and flingUpdate from running. Do we have a new mechanism to prevent recenter and flingUpdate from running while we are dismissing from pan?

1048–1053 ↗(On Diff #47084)

In the old system, this would trigger on panJustEnded, which was based on panActive, which would not be set if the pan started within the button bounds (!outsideButtons).

In contrast, it appears that your new logic will trigger even if the pan starts within the button bounds.

To address this, should we move panActive.value = false; to the bottom of panEnd, and only execute this new logic if (panActive.value)?

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

Looks like D14307 introduces something for this for recentering (isRunningDismissAnimation), but it doesn't appear to be used in D14308 for the fling update

native/components/full-screen-view-modal.react.js
491–492 ↗(On Diff #47084)

I'm surprised to see that we don't seem to handle curScale during the shared transition. Any idea why that is? Am I missing something?

angelika added inline comments.
native/components/full-screen-view-modal.react.js
355 ↗(On Diff #47084)

I'll answer this in the appropriate diffs. In this diff we don't care yet about recenter and fling and activeInteraction and there is no context for the answer.

491–492 ↗(On Diff #47084)

But this code here is a shared transition? For me it looks like an inertia animation when dismissing a modal?

1048–1053 ↗(On Diff #47084)

You're right, fixed. I used early return though, shouldn't matter and the code is less nested.

native/components/full-screen-view-modal.react.js
491–492 ↗(On Diff #47084)

Ah, oops – you're right. The shared transition is handled by the reverseNavigationProgress stuff, which covers x, y, and scale.

1048–1053 ↗(On Diff #47084)

Makes sense, that's definitely cleaner

Add cancelAnimation for curScale