-
-
Notifications
You must be signed in to change notification settings - Fork 538
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,12 @@ | |
// Native components | ||
import ScreenStackNativeComponent from '../fabric/ScreenStackNativeComponent'; | ||
const NativeScreenStack: React.ComponentType<ScreenStackProps> = | ||
ScreenStackNativeComponent as any; | ||
|
||
function isFabric() { | ||
return 'nativeFabricUIManager' in global; | ||
} | ||
|
||
function ScreenStack(props: ScreenStackProps) { | ||
const { children, gestureDetectorBridge, ...rest } = props; | ||
const ref = React.useRef(null); | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
); | ||
|
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.
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).