Skip to content

Commit eb37831

Browse files
committed
Trigger transition only when requested from content wrapper layout
1 parent 416fffc commit eb37831

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

  • android/src/main/java/com/swmansion/rnscreens

android/src/main/java/com/swmansion/rnscreens/Screen.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ class Screen(
8585
var sheetClosesOnTouchOutside = true
8686
var sheetElevation: Float = 24F
8787

88+
/**
89+
* When using form sheet presentation we want to delay enter transition **on Paper** in order
90+
* to wait for initial layout from React, otherwise the animator-based animation will look
91+
* glitchy. *This is not needed on Fabric*.
92+
*/
93+
var shouldTriggerPostponedTransitionAfterLayout = false
94+
8895
var footer: ScreenFooter? = null
8996
set(value) {
9097
if (value == null && field != null) {
@@ -135,6 +142,7 @@ class Screen(
135142

136143
if (!BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
137144
// On old architecture we delay enter transition in order to wait for initial frame.
145+
shouldTriggerPostponedTransitionAfterLayout = true
138146
val parent = parentAsViewGroup()
139147
if (parent != null && !parent.isInLayout) {
140148
// There are reported cases (irreproducible) when Screen is not laid out after
@@ -200,8 +208,11 @@ class Screen(
200208

201209
private fun triggerPostponedEnterTransitionIfNeeded() {
202210
Log.i("RNScreens", "startPostponedEnterTransition")
203-
// This will trigger enter transition only if one was requested by ScreenStack
204-
fragment?.startPostponedEnterTransition()
211+
if (shouldTriggerPostponedTransitionAfterLayout) {
212+
shouldTriggerPostponedTransitionAfterLayout = false
213+
// This will trigger enter transition only if one was requested by ScreenStack
214+
fragment?.startPostponedEnterTransition()
215+
}
205216
}
206217

207218
private fun updateScreenSizePaper(

0 commit comments

Comments
 (0)