Commit 0a0cd0eb authored by isstuev's avatar isstuev

review fix

parent 7ed1aa9f
...@@ -13,17 +13,25 @@ interface Props { ...@@ -13,17 +13,25 @@ interface Props {
const NftImageFullscreen = ({ src, isOpen, onClose }: Props) => { const NftImageFullscreen = ({ src, isOpen, onClose }: Props) => {
const imgRef = React.useRef<HTMLImageElement>(null); const imgRef = React.useRef<HTMLImageElement>(null);
const [ hasDimentions, setHasDimentions ] = React.useState<boolean>(true);
const checkWidth = React.useCallback(() => { const checkWidth = React.useCallback(() => {
if (imgRef.current?.getBoundingClientRect().width === 0) { if (imgRef.current?.getBoundingClientRect().width === 0) {
imgRef.current.style.width = '90vw'; setHasDimentions(false);
imgRef.current.style.height = '90vh';
} }
}, [ ]); }, [ ]);
return ( return (
<NftMediaFullscreenModal isOpen={ isOpen } onClose={ onClose }> <NftMediaFullscreenModal isOpen={ isOpen } onClose={ onClose }>
<Image src={ src } alt="Token instance image" maxH="90vh" maxW="90vw" ref={ imgRef } onLoad={ checkWidth }/> <Image
src={ src }
alt="Token instance image"
maxH="90vh"
maxW="90vw"
ref={ imgRef }
onLoad={ checkWidth }
sx={ hasDimentions ? {} : { width: '90vw', height: '90vh' } }
/>
</NftMediaFullscreenModal> </NftMediaFullscreenModal>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment