@deepnoid/canvas 0.1.25 → 0.1.26

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,63 @@ 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)
136
+ return;
137
+ const canvasEl = resolutionCanvas(canvasRef.current);
138
+ if (!canvasEl)
137
139
  return;
138
- }
139
- console.log(11111111111111111111111111111);
140
140
  if (resetOnImageChange) {
141
- const canvasEl = resolutionCanvas(canvasRef.current);
142
- if (canvasEl)
141
+ if (width && height) {
142
+ console.log('> init (resetOnImageChange true)');
143
143
  init(canvasEl, imageRef.current);
144
+ setImageOnloadCount((prev) => prev + 1);
145
+ }
144
146
  }
145
- setImageOnloadCount((prev) => prev + 1);
146
- }, [imageRef?.current]);
147
+ else {
148
+ drawCanvas(moveX, moveY, zoomX, zoomY, zoom, dx, dy, canvasEl, imageRef.current, true);
149
+ }
150
+ }, [imageRef?.current, width, height, resetOnImageChange]);
147
151
  useEffect(() => {
148
- if (!imageRef?.current || !canvasRef?.current || !width || !height) {
149
- console.log(99999999999999999999999);
152
+ if (!imageRef?.current || !canvasRef?.current)
150
153
  return;
151
- }
152
154
  const canvasEl = resolutionCanvas(canvasRef.current);
153
- if (canvasEl && !resetOnImageChange) {
154
- console.log(333333333333333333333333333333);
155
- init(canvasEl, imageRef.current);
155
+ if (!canvasEl)
156
+ return;
157
+ if (!resetOnImageChange) {
158
+ if (width && height) {
159
+ console.log('> init (resetOnImageChange false, width/height ready)');
160
+ init(canvasEl, imageRef.current);
161
+ setImageOnloadCount((prev) => prev + 1);
162
+ }
163
+ else {
164
+ drawCanvas(moveX, moveY, zoomX, zoomY, zoom, dx, dy, canvasEl, imageRef.current, true);
165
+ }
156
166
  }
157
- setImageOnloadCount((prev) => prev + 1);
158
- }, [width, height]);
167
+ }, [width, height, resetOnImageChange]);
168
+ // useEffect(() => {
169
+ // if (!imageRef?.current || !canvasRef?.current || !width || !height) {
170
+ // console.log(888888888888888888888);
171
+ // return;
172
+ // }
173
+ // console.log(11111111111111111111111111111);
174
+ // if (resetOnImageChange) {
175
+ // const canvasEl = resolutionCanvas(canvasRef.current);
176
+ // if (canvasEl) init(canvasEl, imageRef.current);
177
+ // }
178
+ // setImageOnloadCount((prev) => prev + 1);
179
+ // }, [imageRef?.current]);
180
+ // useEffect(() => {
181
+ // if (!imageRef?.current || !canvasRef?.current || !width || !height) {
182
+ // console.log(99999999999999999999999);
183
+ // return;
184
+ // }
185
+ // const canvasEl = resolutionCanvas(canvasRef.current);
186
+ // if (canvasEl && !resetOnImageChange) {
187
+ // console.log(333333333333333333333333333333);
188
+ // init(canvasEl, imageRef.current);
189
+ // }
190
+ // setImageOnloadCount((prev) => prev + 1);
191
+ // }, [width, height]);
159
192
  return {
160
193
  moveX,
161
194
  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.26",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",