@@ -36,12 +36,13 @@ const AnimatedImage = (props: AnimatedImageProps) => {
3636 loader,
3737 style,
3838 onLoad : propsOnLoad ,
39+ onLoadStart : propsOnLoadStart ,
3940 animationDuration = 300 ,
4041 testID,
4142 ...others
4243 } = props ;
4344
44- const [ isLoading , setIsLoading ] = useState ( true ) ;
45+ const [ isLoading , setIsLoading ] = useState ( false ) ;
4546 const opacity = useSharedValue ( 0 ) ;
4647
4748 useDidUpdate ( ( ) => {
@@ -50,16 +51,23 @@ const AnimatedImage = (props: AnimatedImageProps) => {
5051 }
5152 } , [ loader ] ) ;
5253
53- const onLoad = useCallback ( ( event : NativeSyntheticEvent < ImageLoadEventData > ) => {
54- setIsLoading ( false ) ;
55- propsOnLoad ?.( event ) ;
56- // did not start the animation already
57- if ( opacity . value === 0 ) {
58- opacity . value = withTiming ( 1 , { duration : animationDuration } ) ;
59- }
60- } ,
61- // eslint-disable-next-line react-hooks/exhaustive-deps
62- [ setIsLoading , propsOnLoad , animationDuration ] ) ;
54+ const onLoad = useCallback (
55+ ( event : NativeSyntheticEvent < ImageLoadEventData > ) => {
56+ setIsLoading ( false ) ;
57+ propsOnLoad ?.( event ) ;
58+ // did not start the animation already
59+ if ( opacity . value === 0 ) {
60+ opacity . value = withTiming ( 1 , { duration : animationDuration } ) ;
61+ }
62+ } ,
63+ // eslint-disable-next-line react-hooks/exhaustive-deps
64+ [ setIsLoading , propsOnLoad , animationDuration ]
65+ ) ;
66+
67+ const onLoadStart = useCallback ( ( ) => {
68+ setIsLoading ( true ) ;
69+ propsOnLoadStart ?.( ) ;
70+ } , [ setIsLoading , propsOnLoadStart , animationDuration ] ) ;
6371
6472 const fadeInStyle = useAnimatedStyle ( ( ) => {
6573 return { opacity : opacity . value } ;
@@ -75,6 +83,7 @@ const AnimatedImage = (props: AnimatedImageProps) => {
7583 style = { _style }
7684 source = { source }
7785 onLoad = { onLoad }
86+ onLoadStart = { onLoadStart }
7887 testID = { testID }
7988 imageStyle = { undefined }
8089 />
0 commit comments