Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sherfin94 committed Aug 24, 2022
2 parents a187b38 + c75b627 commit 52da989
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.22.3
1.22.4
14 changes: 13 additions & 1 deletion frontend/src/Editor/Components/Image.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const Image = function Image({ component, height, properties, styles, fir
const imageRef = useRef(null);
const [imageOffset, setImageOffset] = useState(0);
const [rotation, setRotation] = useState(0);
const [zoomReset, setZoomReset] = useState(false);

function Placeholder() {
return <div className="skeleton-image" style={{ objectFit: 'contain', height }}></div>;
Expand All @@ -22,6 +23,11 @@ export const Image = function Image({ component, height, properties, styles, fir
setImageOffset(computeOffset());
}, [imageRef]);

useEffect(() => {
setRotation(0);
setZoomReset(true);
}, [source]);

function computeOffset() {
if (imageRef.current) {
const clientRect = imageRef.current.getBoundingClientRect();
Expand Down Expand Up @@ -57,6 +63,11 @@ export const Image = function Image({ component, height, properties, styles, fir
/>
);

const resetZoom = (resetTransform) => {
setZoomReset(false);
resetTransform();
};

return (
<div
data-disabled={disabledState}
Expand All @@ -81,8 +92,9 @@ export const Image = function Image({ component, height, properties, styles, fir
) : zoomButtons ? (
<>
<TransformWrapper>
{({ zoomIn, zoomOut }) => (
{({ zoomIn, zoomOut, resetTransform }) => (
<>
{zoomReset && resetZoom(resetTransform)}
<TransformComponent>{renderImage()}</TransformComponent>
{zoomButtons && (
<div className="zoom-button-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion server/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.22.3
1.22.4

0 comments on commit 52da989

Please sign in to comment.