@mhamz.01/easyflow-whiteboard 2.96.0 → 2.97.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveUpdate.d.ts","sourceRoot":"","sources":["../../src/hooks/useLiveUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,
|
|
1
|
+
{"version":3,"file":"useLiveUpdate.d.ts","sourceRoot":"","sources":["../../src/hooks/useLiveUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,MAAM,EAA6B,MAAM,QAAQ,CAAC;AAI3D,UAAU,kBAAkB;IAC1B,YAAY,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvC,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,eAAO,MAAM,aAAa,GAAI,+BAA+B,kBAAkB,SAuD9E,CAAC"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import { useEffect
|
|
1
|
+
import { useEffect } from "react";
|
|
2
2
|
import { FabricImage } from "fabric";
|
|
3
3
|
import { Frame } from "../lib/fabric-frame";
|
|
4
4
|
import { calculateDashArray } from "../lib/fabric-utils";
|
|
5
5
|
export const useLiveUpdate = ({ fabricCanvas, toolOptions }) => {
|
|
6
|
-
const prevToolOptionsRef = useRef(null);
|
|
7
6
|
useEffect(() => {
|
|
8
7
|
const canvas = fabricCanvas.current;
|
|
9
8
|
if (!canvas)
|
|
10
9
|
return;
|
|
10
|
+
// ← KEY FIX: This should only run when toolOptions CHANGES
|
|
11
|
+
// Not when selection changes!
|
|
11
12
|
const activeObject = canvas.getActiveObject();
|
|
12
13
|
if (!activeObject)
|
|
13
14
|
return;
|
|
14
|
-
// ← FIX: Only update if toolOptions actually changed
|
|
15
|
-
const prevOptions = prevToolOptionsRef.current;
|
|
16
|
-
if (prevOptions && JSON.stringify(prevOptions) === JSON.stringify(toolOptions)) {
|
|
17
|
-
return; // No changes, skip update
|
|
18
|
-
}
|
|
19
|
-
prevToolOptionsRef.current = toolOptions;
|
|
20
15
|
const updateObjectStyle = (obj) => {
|
|
21
16
|
let options = null;
|
|
22
17
|
if (obj.type === "rect")
|
|
@@ -61,5 +56,5 @@ export const useLiveUpdate = ({ fabricCanvas, toolOptions }) => {
|
|
|
61
56
|
updateObjectStyle(activeObject);
|
|
62
57
|
}
|
|
63
58
|
canvas.requestRenderAll();
|
|
64
|
-
}, [toolOptions
|
|
59
|
+
}, [toolOptions]); // ← REMOVED fabricCanvas from deps - only run when toolOptions changes
|
|
65
60
|
};
|