@deepnoid/canvas 0.1.25 → 0.1.27

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.
@@ -132,30 +132,20 @@ export const usePanZoom = ({ canvasRef, imageRef, panZoomable = false, resetOnIm
132
132
  redraw();
133
133
  }, [moveX, moveY, zoomX, zoomY, zoom, dx, dy, dw, dh, imageOnloadCount, canvasRef, imageRef]);
134
134
  useEffect(() => {
135
- if (!imageRef?.current || !canvasRef?.current || !width || !height) {
136
- console.log(888888888888888888888);
135
+ if (!imageRef?.current || !canvasRef?.current || !width || !height)
137
136
  return;
138
- }
139
- console.log(11111111111111111111111111111);
140
- if (resetOnImageChange) {
141
- const canvasEl = resolutionCanvas(canvasRef.current);
142
- if (canvasEl)
143
- init(canvasEl, imageRef.current);
144
- }
145
- setImageOnloadCount((prev) => prev + 1);
146
- }, [imageRef?.current]);
147
- useEffect(() => {
148
- if (!imageRef?.current || !canvasRef?.current || !width || !height) {
149
- console.log(99999999999999999999999);
150
- return;
151
- }
152
137
  const canvasEl = resolutionCanvas(canvasRef.current);
153
- if (canvasEl && !resetOnImageChange) {
154
- console.log(333333333333333333333333333333);
138
+ if (!canvasEl)
139
+ return;
140
+ const isFirstLoad = imageOnloadCount === 0;
141
+ if (isFirstLoad || resetOnImageChange) {
155
142
  init(canvasEl, imageRef.current);
156
143
  }
144
+ else {
145
+ drawCanvas(moveX, moveY, zoomX, zoomY, zoom, dx, dy, canvasEl, imageRef.current, true);
146
+ }
157
147
  setImageOnloadCount((prev) => prev + 1);
158
- }, [width, height]);
148
+ }, [imageRef?.current, width, height, resetOnImageChange]);
159
149
  return {
160
150
  moveX,
161
151
  moveY,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepnoid/canvas",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",