File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
src/components/LazyChild/hooks Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change 77 useAnimatedReaction ,
88 useDerivedValue ,
99 useSharedValue ,
10- withDelay ,
1110 withTiming ,
1211} from 'react-native-reanimated' ;
1312
@@ -102,28 +101,33 @@ export const useVisibilityCallbacks = ({
102101
103102 useAnimatedReaction (
104103 ( ) => _isVisible . value ,
105- ( isLazyChildVisible ) => {
106- if ( isLazyChildVisible ) {
104+ ( isLazyChildVisible , prevIsVisible ) => {
105+ if ( isLazyChildVisible && ! prevIsVisible ) {
107106 if ( shouldMeasurePercentVisible . value ) {
108107 if ( _visibilityTimer . value > 0 ) {
109108 cancelAnimation ( _visibilityTimer ) ;
110109 _visibilityTimer . value = 0 ;
111110 }
112111
113- if ( minimumVisibilityMs ) {
114- _visibilityTimer . value = withDelay (
115- minimumVisibilityMs ,
116- withTiming ( 1 , { duration : 0 } , ( finished ) => {
112+ if ( minimumVisibilityMs && minimumVisibilityMs > 0 ) {
113+ _visibilityTimer . value = withTiming (
114+ 1 ,
115+ { duration : minimumVisibilityMs } ,
116+ ( finished ) => {
117117 if ( finished ) {
118118 runOnJS ( handleOnVisibilityEntered ) ( ) ;
119119 }
120- } )
120+ }
121121 ) ;
122122 } else {
123123 runOnJS ( handleOnVisibilityEntered ) ( ) ;
124124 }
125125 }
126- } else {
126+ }
127+
128+ if ( ! isLazyChildVisible && prevIsVisible ) {
129+ cancelAnimation ( _visibilityTimer ) ;
130+
127131 if ( shouldFireVisibilityExit . value ) {
128132 runOnJS ( handleOnVisibilityExited ) ( ) ;
129133 }
You can’t perform that action at this time.
0 commit comments