diff --git a/frontend/src/Editor/Components/Image.jsx b/frontend/src/Editor/Components/Image.jsx index 3461ffad41..0877742412 100644 --- a/frontend/src/Editor/Components/Image.jsx +++ b/frontend/src/Editor/Components/Image.jsx @@ -3,7 +3,7 @@ import React, { useRef, useEffect, useState } from 'react'; import LazyLoad, { forceCheck } from 'react-lazyload'; import { TransformWrapper, TransformComponent } from 'react-zoom-pan-pinch'; -export const Image = function Image({ component, height, properties, styles, fireEvent, width }) { +export const Image = function Image({ component, height, properties, styles, fireEvent, width, parentId = null }) { const { source, loadingState, alternativeText, zoomButtons, rotateButton } = properties; const { visibility, disabledState, borderType, backgroundColor, padding, imageFit } = styles; const { @@ -20,7 +20,9 @@ export const Image = function Image({ component, height, properties, styles, fir return
; } useEffect(() => { - setImageOffset(computeOffset()); + if (parentId === null) { + setImageOffset(computeOffset()); + } }, [imageRef]); useEffect(() => { @@ -68,6 +70,53 @@ export const Image = function Image({ component, height, properties, styles, fir resetTransform(); }; + const renderImageContainer = () => { + return ( + <> + {loadingState === true ? ( +
+
+
+ ) : zoomButtons ? ( + + {({ zoomIn, zoomOut, resetTransform }) => ( + <> + {zoomReset && resetZoom(resetTransform)} + {renderImage()} + {zoomButtons && ( +
+ {rotateButton && ( + + )} + + +
+ )} + + )} +
+ ) : ( + <> + {rotateButton && ( +
+ +
+ )} + {renderImage()} + + )} + + ); + }; + return (
- {imageRef.current && ( + {imageRef.current && parentId === null ? ( 0 ? imageOffset : 0} height={height} placeholder={} debounce={500} + scrollContainer={'.canvas-container'} > - {loadingState === true ? ( -
-
-
- ) : zoomButtons ? ( - <> - - {({ zoomIn, zoomOut, resetTransform }) => ( - <> - {zoomReset && resetZoom(resetTransform)} - {renderImage()} - {zoomButtons && ( -
- {rotateButton && ( - - )} - - -
- )} - - )} -
- - ) : ( - <> - {rotateButton && ( -
- -
- )} - {renderImage()} - - )} + {renderImageContainer()}
+ ) : ( + imageRef.current && renderImageContainer() )}
);