diff --git a/src/shared/components/image/image.module.css b/src/shared/components/image/image.module.css index 5ffb0b0f..2fbb2eef 100644 --- a/src/shared/components/image/image.module.css +++ b/src/shared/components/image/image.module.css @@ -32,3 +32,8 @@ width: 100%; height: 100%; } + +.view-wrapper { + width: 100%; + height: 100%; +} diff --git a/src/shared/components/image/image.tsx b/src/shared/components/image/image.tsx index 61865177..d4f2e910 100644 --- a/src/shared/components/image/image.tsx +++ b/src/shared/components/image/image.tsx @@ -1,6 +1,6 @@ import clsx from 'clsx'; import { motion, MotionConfigProps } from 'motion/react'; -import { type ImgHTMLAttributes } from 'react'; +import { ForwardedRef, forwardRef, type ImgHTMLAttributes } from 'react'; import { Img } from 'react-image'; import { InView } from 'react-intersection-observer'; @@ -50,35 +50,34 @@ export function Image({ return ( {({ inView, ref }) => ( -
- ( - - {children} + ( + + {children} + + )} + loader={ + includeLoader ? ( + + - )} - loader={ - includeLoader ? ( - - - - ) : null - } - src={inView ? src : FALLBACK_SVG} - unloader={ - includeUnloader ? ( - - - - ) : null - } - /> -
+ ) : null + } + src={inView ? src : FALLBACK_SVG} + unloader={ + includeUnloader ? ( + + + + ) : null + } + /> )}
); @@ -87,25 +86,31 @@ export function Image({ return ; } -function ImageContainer({ children, className, enableAnimation, ...props }: ImageContainerProps) { - if (!enableAnimation) { - return ( -
- {children} -
- ); - } +const ImageContainer = forwardRef( + ( + { children, className, enableAnimation, ...props }: ImageContainerProps, + ref: ForwardedRef, + ) => { + if (!enableAnimation) { + return ( +
+ {children} +
+ ); + } - return ( - - {children} - - ); -} + return ( + + {children} + + ); + }, +); function ImageLoader({ className }: ImageLoaderProps) { return ( @@ -118,7 +123,7 @@ function ImageLoader({ className }: ImageLoaderProps) { function ImageUnloader({ className }: ImageUnloaderProps) { return (
- +
); }