@deepnoid/canvas 0.1.78 → 0.1.79
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.
|
@@ -114,11 +114,14 @@ export class AnnotationEngine {
|
|
|
114
114
|
this.drawCanvas(this.annotationsCanvas, undefined);
|
|
115
115
|
}
|
|
116
116
|
drawCanvas(canvas, image) {
|
|
117
|
-
const { moveX, moveY, zoomX, zoomY, dx, dy, zoom } = this.getImageCanvasState();
|
|
118
117
|
const context = canvas.getContext('2d');
|
|
119
118
|
if (!context)
|
|
120
119
|
return;
|
|
120
|
+
context.save();
|
|
121
|
+
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
121
122
|
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
123
|
+
context.restore();
|
|
124
|
+
const { moveX, moveY, zoomX, zoomY, dx, dy, zoom } = this.getImageCanvasState();
|
|
122
125
|
context.save();
|
|
123
126
|
context.translate(dx, dy);
|
|
124
127
|
context.translate(moveX, moveY);
|
|
@@ -117,7 +117,6 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
|
|
|
117
117
|
engineRef.current = engine;
|
|
118
118
|
imageLoadingRef.current = false;
|
|
119
119
|
if (pendingAnnotationsRef.current && pendingAnnotationsRef.current.length > 0) {
|
|
120
|
-
console.log('Applying pending annotations after image load:', pendingAnnotationsRef.current.length);
|
|
121
120
|
engine.setAnnotations(pendingAnnotationsRef.current);
|
|
122
121
|
engine.commitHistory();
|
|
123
122
|
}
|
|
@@ -146,24 +145,12 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
|
|
|
146
145
|
}, [image, resetOnImageChange]);
|
|
147
146
|
/* ---------- External annotations ---------- */
|
|
148
147
|
useEffect(() => {
|
|
149
|
-
console.log('External annotations effect:', {
|
|
150
|
-
imageLoading: imageLoadingRef.current,
|
|
151
|
-
hasEngine: !!engineRef.current,
|
|
152
|
-
annotationsLength: annotations.length,
|
|
153
|
-
pendingLength: pendingAnnotationsRef.current?.length,
|
|
154
|
-
});
|
|
155
148
|
if (imageLoadingRef.current || !engineRef.current) {
|
|
156
|
-
console.log('Saving to pending annotations');
|
|
157
149
|
pendingAnnotationsRef.current = annotations;
|
|
158
150
|
return;
|
|
159
151
|
}
|
|
160
152
|
const before = engineRef.current.getAnnotations();
|
|
161
|
-
console.log('Comparing annotations:', {
|
|
162
|
-
before: before.length,
|
|
163
|
-
after: annotations.length,
|
|
164
|
-
});
|
|
165
153
|
if (JSON.stringify(before) !== JSON.stringify(annotations)) {
|
|
166
|
-
console.log('Setting new annotations to engine');
|
|
167
154
|
engineRef.current.setAnnotations(annotations);
|
|
168
155
|
engineRef.current.commitHistory();
|
|
169
156
|
}
|