Skip to content

Commit

Permalink
Fix rendering issue
Browse files Browse the repository at this point in the history
  • Loading branch information
morpheus-87 committed Feb 16, 2024
1 parent 98abfb1 commit ce229aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]

### Fixed

- Fixed rendering issue

## [0.1.7](https://github.com/dbmdz/mirador-imagecropper/releases/tag/0.1.7) - 2023-03-23

### Changed
Expand Down
28 changes: 11 additions & 17 deletions src/components/CroppingOverlay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ const CroppingOverlay = ({
viewType,
}) => {
const { active, dialogOpen, enabled } = config;
const canvasWidth = currentCanvas?.getWidth();
const canvasHeight = currentCanvas?.getHeight();
const currentImage = viewer?.world?.getItemAt(0);
const isInitialRenderOfCanvas = Object.entries(croppingRegion)
.filter(([k]) => k !== "imageCoordinates")
.every(([, v]) => v === 0);
Expand All @@ -111,15 +114,15 @@ const CroppingOverlay = ({
useEffect(() => {
if (isInitialRenderOfCanvas) {
setButtonOutside(true);
/* Set initial region dependant on the current image if this is the initial render for the canvas */
if (currentCanvas && currentImage) {
setCroppingRegion(
getInitialRegion(currentImage, canvasWidth, canvasHeight),
);
}
}
}, [isInitialRenderOfCanvas]);
if (
!enabled ||
!active ||
!viewer ||
!currentCanvas ||
viewType !== "single"
) {
}, [currentCanvas, currentImage, isInitialRenderOfCanvas]);
if (!enabled || !active || viewType !== "single") {
return null;
}
/*
Expand All @@ -135,15 +138,6 @@ const CroppingOverlay = ({
if (rotation !== 0) {
resetRotation();
}
const canvasWidth = currentCanvas.getWidth();
const canvasHeight = currentCanvas.getHeight();
const currentImage = viewer.world.getItemAt(0);
/* Set initial region dependant on the current image if this is the initial render for the canvas */
if (currentImage && isInitialRenderOfCanvas) {
setCroppingRegion(
getInitialRegion(currentImage, canvasWidth, canvasHeight),
);
}
const ResizeHandle = <div className={resizeHandle} />;
return (
<Rnd
Expand Down

0 comments on commit ce229aa

Please sign in to comment.