@@ -22,7 +22,7 @@ import { escapeHTMLTag } from '~/utils/utils'
2222
2323import { LazyLoad } from '../Lazyload'
2424import styles from './index.module.css'
25- import { useCalculateSize } from './use-calculate-size'
25+ import { useCalculateNaturalSize } from './use-calculate-size'
2626
2727interface ImageProps {
2828 defaultImage ?: string
@@ -77,13 +77,20 @@ const Image: FC<
7777 ! loaded && styles [ 'image-hide' ] ,
7878 ) }
7979 data-status = { loaded ? 'loaded' : 'loading' }
80+ onAnimationEnd = { onImageAnimationEnd }
8081 >
8182 < img src = { src } alt = { alt } ref = { imageRef } loading = "lazy" />
8283 </ div >
8384 </ >
8485 )
8586} )
8687
88+ const onImageAnimationEnd : React . AnimationEventHandler < HTMLDivElement > = (
89+ e ,
90+ ) => {
91+ ; ( e . target as HTMLElement ) . dataset . animated = '1'
92+ }
93+
8794export type ImageLazyRef = { status : 'loading' | 'loaded' }
8895
8996export const ImageLazy = memo (
@@ -92,6 +99,9 @@ export const ImageLazy = memo(
9299 ImageProps &
93100 DetailedHTMLProps < ImgHTMLAttributes < HTMLImageElement > , HTMLImageElement >
94101 > ( ( props , ref ) => {
102+ useEffect ( ( ) => {
103+ console . log ( 'update' )
104+ } )
95105 const {
96106 defaultImage,
97107 src,
@@ -114,7 +124,7 @@ export const ImageLazy = memo(
114124 const placeholderRef = useRef < HTMLDivElement > ( null )
115125
116126 const wrapRef = useRef < HTMLDivElement > ( null )
117- const [ calculatedSize , calculateDimensions ] = useCalculateSize ( )
127+ const [ calculatedSize , calculateDimensions ] = useCalculateNaturalSize ( )
118128
119129 const [ loaded , setLoad ] = useState ( false )
120130 const loaderFn = useCallback ( ( ) => {
0 commit comments