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(Fabric): not working animations on second-top screen #2270

Merged
merged 1 commit into from
Jul 31, 2024
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
12 changes: 11 additions & 1 deletion src/components/ScreenStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
// Native components
import ScreenStackNativeComponent from '../fabric/ScreenStackNativeComponent';
const NativeScreenStack: React.ComponentType<ScreenStackProps> =
ScreenStackNativeComponent as any;

Check warning on line 8 in src/components/ScreenStack.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

Unexpected any. Specify a different type

function isFabric() {
return 'nativeFabricUIManager' in global;
}
Comment on lines +10 to +12
Copy link
Member

Choose a reason for hiding this comment

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

IIRC this should be reliably available during the very first render, so we're safe on that front (the value won't differ on first & consecutive renders).


function ScreenStack(props: ScreenStackProps) {
const { children, gestureDetectorBridge, ...rest } = props;
const ref = React.useRef(null);
Expand All @@ -19,8 +23,14 @@
const isFreezeEnabled =
descriptor?.options?.freezeOnBlur ?? freezeEnabled();

// On Fabric, when screen is frozen, animated and reanimated values are not updated
// due to component being unmounted. To avoid this, we don't freeze the previous screen there
const freezePreviousScreen = isFabric()
? size - index > 2
: size - index > 1;
Comment on lines +28 to +30
Copy link
Member

Choose a reason for hiding this comment

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

We need to keep in mind that this is only a heuristics anyway and animations won't work on third-top screen etc.

For now we can proceed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can only see this as a problem when we have multiple transparent modals, in which case I wouldn't enable freeze on that navigator anyway.


return (
<DelayedFreeze freeze={isFreezeEnabled && size - index > 1}>
<DelayedFreeze freeze={isFreezeEnabled && freezePreviousScreen}>
{child}
</DelayedFreeze>
);
Expand Down
Loading