@dcg-overseas/number-line 1.0.0-beta.3 → 1.0.0-beta.4
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.
- package/dist/index.cjs +11 -15
- package/dist/index.js +11 -15
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -289,7 +289,6 @@ function NumberLineProvider({
|
|
|
289
289
|
onChange: onViewChange
|
|
290
290
|
});
|
|
291
291
|
const [liveStroke, setLiveStroke] = React.useState(null);
|
|
292
|
-
const svgPoint = React.useRef(null);
|
|
293
292
|
const [eraseHoverIds, setEraseHoverIds] = React.useState(/* @__PURE__ */ new Set());
|
|
294
293
|
const eraseGesture = React.useRef(null);
|
|
295
294
|
const createHistorySnapshot = React.useCallback(
|
|
@@ -319,20 +318,17 @@ function NumberLineProvider({
|
|
|
319
318
|
drawing.resetStrokes,
|
|
320
319
|
history.clear
|
|
321
320
|
]);
|
|
322
|
-
const getLocalCoords = React.useCallback(
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
},
|
|
334
|
-
[svgRef]
|
|
335
|
-
);
|
|
321
|
+
const getLocalCoords = React.useCallback((event) => {
|
|
322
|
+
const svg = svgRef.current;
|
|
323
|
+
if (!svg) return null;
|
|
324
|
+
const rect = svg.getBoundingClientRect();
|
|
325
|
+
const viewBox = svg.viewBox.baseVal;
|
|
326
|
+
if (rect.width <= 0 || rect.height <= 0 || viewBox.width <= 0 || viewBox.height <= 0) return null;
|
|
327
|
+
return [
|
|
328
|
+
viewBox.x + (event.clientX - rect.left) / rect.width * viewBox.width,
|
|
329
|
+
viewBox.y + (event.clientY - rect.top) / rect.height * viewBox.height
|
|
330
|
+
];
|
|
331
|
+
}, [svgRef]);
|
|
336
332
|
const strokeIdsNear = React.useCallback(
|
|
337
333
|
(x, y, radius) => {
|
|
338
334
|
const ids = [];
|
package/dist/index.js
CHANGED
|
@@ -287,7 +287,6 @@ function NumberLineProvider({
|
|
|
287
287
|
onChange: onViewChange
|
|
288
288
|
});
|
|
289
289
|
const [liveStroke, setLiveStroke] = useState(null);
|
|
290
|
-
const svgPoint = useRef(null);
|
|
291
290
|
const [eraseHoverIds, setEraseHoverIds] = useState(/* @__PURE__ */ new Set());
|
|
292
291
|
const eraseGesture = useRef(null);
|
|
293
292
|
const createHistorySnapshot = useCallback(
|
|
@@ -317,20 +316,17 @@ function NumberLineProvider({
|
|
|
317
316
|
drawing.resetStrokes,
|
|
318
317
|
history.clear
|
|
319
318
|
]);
|
|
320
|
-
const getLocalCoords = useCallback(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
},
|
|
332
|
-
[svgRef]
|
|
333
|
-
);
|
|
319
|
+
const getLocalCoords = useCallback((event) => {
|
|
320
|
+
const svg = svgRef.current;
|
|
321
|
+
if (!svg) return null;
|
|
322
|
+
const rect = svg.getBoundingClientRect();
|
|
323
|
+
const viewBox = svg.viewBox.baseVal;
|
|
324
|
+
if (rect.width <= 0 || rect.height <= 0 || viewBox.width <= 0 || viewBox.height <= 0) return null;
|
|
325
|
+
return [
|
|
326
|
+
viewBox.x + (event.clientX - rect.left) / rect.width * viewBox.width,
|
|
327
|
+
viewBox.y + (event.clientY - rect.top) / rect.height * viewBox.height
|
|
328
|
+
];
|
|
329
|
+
}, [svgRef]);
|
|
334
330
|
const strokeIdsNear = useCallback(
|
|
335
331
|
(x, y, radius) => {
|
|
336
332
|
const ids = [];
|