@deepnoid/canvas 0.1.65 → 0.1.67
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.
|
@@ -34,13 +34,10 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
|
|
|
34
34
|
enabled: enableHotkeys,
|
|
35
35
|
});
|
|
36
36
|
/* ---------- Image / Engine lifecycle ---------- */
|
|
37
|
-
const isInitialLoadRef = useRef(true);
|
|
38
37
|
const imageLoadingRef = useRef(false);
|
|
39
38
|
useEffect(() => {
|
|
40
39
|
imageLoadingRef.current = true;
|
|
41
|
-
|
|
42
|
-
engineRef.current.setAnnotations([]);
|
|
43
|
-
}
|
|
40
|
+
pendingAnnotationsRef.current = null;
|
|
44
41
|
if (!image?.trim()) {
|
|
45
42
|
engineRef.current?.destroy();
|
|
46
43
|
engineRef.current = null;
|
|
@@ -69,11 +66,9 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
|
|
|
69
66
|
dh: img.height,
|
|
70
67
|
initZoom: 1,
|
|
71
68
|
};
|
|
72
|
-
const initialAnnotations =
|
|
73
|
-
|
|
74
|
-
: (pendingAnnotationsRef.current ?? []);
|
|
69
|
+
const initialAnnotations = pendingAnnotationsRef.current ?? [];
|
|
70
|
+
console.log('> AnnotationCanvas - initialAnnotations : ', initialAnnotations, ', pendingAnnotationsRef.current : ', pendingAnnotationsRef.current, ', annotations prop : ', annotations);
|
|
75
71
|
pendingAnnotationsRef.current = null;
|
|
76
|
-
isInitialLoadRef.current = false;
|
|
77
72
|
prevEngine?.destroy();
|
|
78
73
|
engineRef.current = new AnnotationEngine({
|
|
79
74
|
imageCanvas: imageCanvasRef.current,
|
|
@@ -113,11 +108,7 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
|
|
|
113
108
|
useEffect(() => {
|
|
114
109
|
if (!annotations)
|
|
115
110
|
return;
|
|
116
|
-
if (imageLoadingRef.current) {
|
|
117
|
-
pendingAnnotationsRef.current = annotations;
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (!engineRef.current) {
|
|
111
|
+
if (imageLoadingRef.current || !engineRef.current) {
|
|
121
112
|
pendingAnnotationsRef.current = annotations;
|
|
122
113
|
return;
|
|
123
114
|
}
|