1
1
import type { PropsWithChildren , ReactNode } from 'react' ;
2
2
import { useEffect } from 'react' ;
3
+ import type { ViewStyle } from 'react-native' ;
3
4
import type { SharedValue } from 'react-native-reanimated' ;
4
5
import {
5
6
runOnJS ,
@@ -8,9 +9,20 @@ import {
8
9
useSharedValue
9
10
} from 'react-native-reanimated' ;
10
11
12
+ import { IS_WEB } from '../../../constants' ;
11
13
import { usePortalContext , useTeleportedItemId } from '../../../providers' ;
12
14
import type { AnimatedStyleProp , MeasureCallback } from '../../../types' ;
13
15
16
+ const TELEPORTED_ITEM_STYLE : ViewStyle = {
17
+ maxHeight : 0 ,
18
+ overflow : 'hidden'
19
+ } ;
20
+
21
+ const NOT_TELEPORTED_ITEM_STYLE : ViewStyle = {
22
+ maxHeight : IS_WEB ? 9999 : 'auto' , // 'auto' doesn't trigger onLayout on web
23
+ overflow : 'visible'
24
+ } ;
25
+
14
26
type ActiveItemPortalProps = PropsWithChildren < {
15
27
itemKey : string ;
16
28
activationAnimationProgress : SharedValue < number > ;
@@ -75,10 +87,9 @@ export default function ActiveItemPortal({
75
87
}
76
88
} ;
77
89
78
- const animatedItemStyle = useAnimatedStyle ( ( ) => ( {
79
- maxHeight : isTeleported . value ? 0 : 'auto' ,
80
- overflow : isTeleported . value ? 'hidden' : 'visible'
81
- } ) ) ;
90
+ const animatedItemStyle = useAnimatedStyle ( ( ) =>
91
+ isTeleported . value ? TELEPORTED_ITEM_STYLE : NOT_TELEPORTED_ITEM_STYLE
92
+ ) ;
82
93
83
94
useAnimatedReaction (
84
95
( ) => activationAnimationProgress . value ,
0 commit comments