@@ -50,7 +50,6 @@ type SceneRoute = {
5050 * - [X] Use animValue from started navigator
5151 * - [X] Use route from deepest nested scene
5252 * - [X] Support nesting
53- * - [ ] State gets messed up when transition hasnt ended yet (stops working)
5453 * - [ ] Not all lifecycle events not emitted by stack when using gestures (close modal)
5554 */
5655
@@ -77,6 +76,15 @@ export default class SharedElementRendererData
7776 this . route = null ;
7877 this . animValue = null ;
7978
79+ // When a transition wasn't completely fully, but a new transition
80+ // has already started, then the `willBlur` event is not called.
81+ // For this particular case, we capture the animation-value of the
82+ // last (previous) scene that is now being hidden.
83+ if ( this . isTransitionStarted && this . prevRoute ) {
84+ const scene = this . getScene ( this . prevRoute ) ;
85+ if ( scene ) this . animValue = scene . getAnimValue ( true ) ;
86+ }
87+
8088 this . isTransitionStarted = true ;
8189 this . isTransitionClosing = closing ;
8290 this . transitionNavigatorId = navigatorId ;
@@ -127,9 +135,11 @@ export default class SharedElementRendererData
127135 // started the transition
128136 if (
129137 ! this . isTransitionClosing &&
130- sceneData . navigatorId === this . transitionNavigatorId
138+ this . prevRoute &&
139+ sceneData . navigatorId === this . transitionNavigatorId &&
140+ ! this . animValue
131141 ) {
132- this . animValue = sceneData . getAnimValue ( this . isTransitionClosing ) ;
142+ this . animValue = sceneData . getAnimValue ( false ) ;
133143 }
134144
135145 // In case of nested navigators, multiple scenes will become
@@ -176,9 +186,10 @@ export default class SharedElementRendererData
176186 // started the transition
177187 if (
178188 this . isTransitionClosing &&
179- sceneData . navigatorId === this . transitionNavigatorId
189+ sceneData . navigatorId === this . transitionNavigatorId &&
190+ ! this . animValue
180191 ) {
181- this . animValue = sceneData . getAnimValue ( this . isTransitionClosing ) ;
192+ this . animValue = sceneData . getAnimValue ( true ) ;
182193 }
183194
184195 // Update transition
@@ -194,7 +205,7 @@ export default class SharedElementRendererData
194205 route,
195206 subscription : null ,
196207 } ) ;
197- if ( this . scenes . length > 5 ) {
208+ if ( this . scenes . length > 10 ) {
198209 const { subscription } = this . scenes [ 0 ] ;
199210 this . scenes . splice ( 0 , 1 ) ;
200211 if ( subscription ) subscription . remove ( ) ;
@@ -255,7 +266,9 @@ export default class SharedElementRendererData
255266 'updateSharedElements: ',
256267 sharedElements,
257268 ' ,isShowing: ',
258- isShowing
269+ isShowing,
270+ ', animValue: ',
271+ animValue
259272 );*/
260273 this . emitUpdateEvent ( ) ;
261274 }
@@ -275,13 +288,22 @@ export default class SharedElementRendererData
275288 }
276289
277290 getTransitions ( ) : SharedElementTransitionProps [ ] {
278- const { sharedElements, prevScene, scene, isShowing, animValue } = this ;
291+ const {
292+ sharedElements,
293+ prevScene,
294+ scene,
295+ isShowing,
296+ animValue,
297+ route,
298+ } = this ;
279299
280- if ( ! sharedElements || ! scene || ! prevScene ) return NO_SHARED_ELEMENTS ;
300+ if ( ! sharedElements || ! scene || ! prevScene || ! route )
301+ return NO_SHARED_ELEMENTS ;
281302 return sharedElements . map ( ( { id, otherId, ...other } ) => {
282303 const startId = isShowing ? otherId || id : id ;
283304 const endId = isShowing ? id : otherId || id ;
284305 return {
306+ key : route . key ,
285307 position : animValue ,
286308 start : {
287309 ancestor : ( prevScene ? prevScene . getAncestor ( ) : undefined ) || null ,
0 commit comments