@deepnoid/canvas 0.1.23 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,14 +17,9 @@ const AnnotatedCanvas = ({ image, coordinates, panZoomable = false, ZoomButton,
|
|
|
17
17
|
const loaded = loadedImage && !isLoading;
|
|
18
18
|
useEffect(() => {
|
|
19
19
|
if (loaded) {
|
|
20
|
-
setDisplayCoordinates(coordinates);
|
|
20
|
+
setDisplayCoordinates(loaded ? coordinates : undefined);
|
|
21
21
|
}
|
|
22
22
|
}, [loaded, coordinates]);
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (isLoading) {
|
|
25
|
-
setDisplayCoordinates(undefined);
|
|
26
|
-
}
|
|
27
|
-
}, [isLoading]);
|
|
28
23
|
if (!image || error)
|
|
29
24
|
return null;
|
|
30
25
|
return (_jsx("div", { style: { width: '100%', height: '100%', display: 'flex', flex: 1 }, children: _jsx("div", { onWheel: handleWheel, onMouseMove: handleMouseMove, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onMouseLeave: handleMouseLeave, style: {
|
package/dist/hooks/usePanZoom.js
CHANGED
|
@@ -73,14 +73,6 @@ export const usePanZoom = ({ canvasRef, imageRef, panZoomable = false, resetOnIm
|
|
|
73
73
|
setImageOnloadCount((prev) => prev + 1);
|
|
74
74
|
}
|
|
75
75
|
}, [imageRef?.current, resetOnImageChange]);
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
const redraw = () => {
|
|
78
|
-
if (canvasRef.current && imageRef?.current) {
|
|
79
|
-
drawCanvas(moveX, moveY, zoomX, zoomY, zoom, dx, dy, resolutionCanvas(canvasRef.current), imageRef.current, true);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
redraw();
|
|
83
|
-
}, [moveX, moveY, zoomX, zoomY, zoom, dx, dy, dw, dh, imageOnloadCount, canvasRef, imageRef]);
|
|
84
76
|
useEffect(() => {
|
|
85
77
|
if (!imageRef?.current)
|
|
86
78
|
return;
|
|
@@ -89,7 +81,15 @@ export const usePanZoom = ({ canvasRef, imageRef, panZoomable = false, resetOnIm
|
|
|
89
81
|
init(canvasEl, imageRef.current);
|
|
90
82
|
setImageOnloadCount((prev) => prev + 1);
|
|
91
83
|
}
|
|
92
|
-
}, [width, height, resetOnImageChange
|
|
84
|
+
}, [width, height, resetOnImageChange]);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const redraw = () => {
|
|
87
|
+
if (canvasRef.current && imageRef?.current) {
|
|
88
|
+
drawCanvas(moveX, moveY, zoomX, zoomY, zoom, dx, dy, resolutionCanvas(canvasRef.current), imageRef.current, true);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
redraw();
|
|
92
|
+
}, [moveX, moveY, zoomX, zoomY, zoom, dx, dy, dw, dh, imageOnloadCount, canvasRef, imageRef]);
|
|
93
93
|
const handleWheel = (event) => {
|
|
94
94
|
if (!panZoomable || !canvasRef.current || !imageRef?.current)
|
|
95
95
|
return;
|