Skip to content
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

fix: gesture direction for left modal stack #37601

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ const commonScreenOptions: StackNavigationOptions = {
animationTypeForReplace: 'push',
};

const SLIDE_LEFT_OUTPUT_RANGE_MULTIPLIER = -1;

type GetRootNavigatorScreenOptions = (isSmallScreenWidth: boolean, styles: ThemeStyles, StyleUtils: StyleUtilsType) => ScreenOptions;

const getRootNavigatorScreenOptions: GetRootNavigatorScreenOptions = (isSmallScreenWidth, themeStyles, StyleUtils) => {
Expand All @@ -41,8 +39,9 @@ const getRootNavigatorScreenOptions: GetRootNavigatorScreenOptions = (isSmallScr
},
leftModalNavigator: {
...commonScreenOptions,
cardStyleInterpolator: (props) => modalCardStyleInterpolator(isSmallScreenWidth, false, props, SLIDE_LEFT_OUTPUT_RANGE_MULTIPLIER),
Copy link
Contributor

@youssef-lr youssef-lr Mar 5, 2024

Choose a reason for hiding this comment

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

I'm curious what this does SLIDE_LEFT_OUTPUT_RANGE_MULTIPLIER, @kirillzyusko? And why did we remove it after changing the direction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@youssef-lr basically it was reverting the animation. And when we multiply extrapolated values (let's say we move screen from 0 to 336) by -1 - we change a direction of animation.

But in react-navigation this -1 multiplier is already handled if you specify gestureDirection.

So if I specify gestureDirection as horizontal-inverted - it'll automatically drive the animation from left to right, but since we multiplied it before by -1 we kind of getting double inversion which results in right-to-left (default) animation.

That's why I removed this - I delegated a control fully to react-navigation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh makes sense, thanks for clarifying!

cardStyleInterpolator: (props) => modalCardStyleInterpolator(isSmallScreenWidth, false, props),
presentation: 'transparentModal',
gestureDirection: 'horizontal-inverted',

// We want pop in LHP since there are some flows that would work weird otherwise
animationTypeForReplace: 'pop',
Expand Down
Loading