Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rendering issue #218

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

- Fixed `engine` restriction

### 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
Loading