canvu-react 0.4.16 → 0.4.17
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/native.cjs +46 -5
- package/dist/native.cjs.map +1 -1
- package/dist/native.js +46 -5
- package/dist/native.js.map +1 -1
- package/package.json +1 -1
package/dist/native.cjs
CHANGED
|
@@ -3612,6 +3612,10 @@ function nativeCursorForVectorToolId(toolId) {
|
|
|
3612
3612
|
return null;
|
|
3613
3613
|
}
|
|
3614
3614
|
}
|
|
3615
|
+
function nativeFallbackToolCursorPoint(size) {
|
|
3616
|
+
if (size.width <= 0 || size.height <= 0) return null;
|
|
3617
|
+
return { x: size.width / 2, y: size.height / 2 };
|
|
3618
|
+
}
|
|
3615
3619
|
var MIN_PLACE_SIZE = 8;
|
|
3616
3620
|
var MIN_ARROW_DRAG_PX = 8;
|
|
3617
3621
|
var TAP_PX = 20;
|
|
@@ -3827,10 +3831,25 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
|
|
|
3827
3831
|
setCameraTick((n) => n + 1);
|
|
3828
3832
|
onCameraChangeRef.current?.();
|
|
3829
3833
|
}, []);
|
|
3830
|
-
const onLayout = react.useCallback(
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
+
const onLayout = react.useCallback(
|
|
3835
|
+
(e) => {
|
|
3836
|
+
const { width, height } = e.nativeEvent.layout;
|
|
3837
|
+
const nextSize = { width, height };
|
|
3838
|
+
setSize(nextSize);
|
|
3839
|
+
if (!interactive) {
|
|
3840
|
+
setToolCursorPoint(null);
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3843
|
+
if (!nativeCursorForVectorToolId(toolIdRef.current)) {
|
|
3844
|
+
setToolCursorPoint(null);
|
|
3845
|
+
return;
|
|
3846
|
+
}
|
|
3847
|
+
setToolCursorPoint(
|
|
3848
|
+
(current) => current ?? nativeFallbackToolCursorPoint(nextSize)
|
|
3849
|
+
);
|
|
3850
|
+
},
|
|
3851
|
+
[interactive]
|
|
3852
|
+
);
|
|
3834
3853
|
const updateToolCursorPoint = react.useCallback(
|
|
3835
3854
|
(point) => {
|
|
3836
3855
|
if (!interactive) return;
|
|
@@ -3842,6 +3861,25 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
|
|
|
3842
3861
|
const hideToolCursor = react.useCallback(() => {
|
|
3843
3862
|
setToolCursorPoint(null);
|
|
3844
3863
|
}, []);
|
|
3864
|
+
const showFallbackToolCursor = react.useCallback(
|
|
3865
|
+
(nextToolId) => {
|
|
3866
|
+
if (!interactive) {
|
|
3867
|
+
setToolCursorPoint(null);
|
|
3868
|
+
return;
|
|
3869
|
+
}
|
|
3870
|
+
if (!nativeCursorForVectorToolId(nextToolId)) {
|
|
3871
|
+
setToolCursorPoint(null);
|
|
3872
|
+
return;
|
|
3873
|
+
}
|
|
3874
|
+
setToolCursorPoint(
|
|
3875
|
+
(current) => current ?? nativeFallbackToolCursorPoint(size)
|
|
3876
|
+
);
|
|
3877
|
+
},
|
|
3878
|
+
[interactive, size]
|
|
3879
|
+
);
|
|
3880
|
+
react.useEffect(() => {
|
|
3881
|
+
showFallbackToolCursor(toolId);
|
|
3882
|
+
}, [showFallbackToolCursor, toolId]);
|
|
3845
3883
|
const handlePointerMove = react.useCallback(
|
|
3846
3884
|
(event) => {
|
|
3847
3885
|
updateToolCursorPoint(screenPointFromPointerEvent(event));
|
|
@@ -4127,7 +4165,10 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
|
|
|
4127
4165
|
onPanResponderRelease: (evt) => {
|
|
4128
4166
|
lastPinchDist.current = null;
|
|
4129
4167
|
lastPanPoint.current = null;
|
|
4130
|
-
|
|
4168
|
+
updateToolCursorPoint({
|
|
4169
|
+
x: evt.nativeEvent.locationX,
|
|
4170
|
+
y: evt.nativeEvent.locationY
|
|
4171
|
+
});
|
|
4131
4172
|
const st = dragStateRef.current;
|
|
4132
4173
|
if (st.kind === "draw") {
|
|
4133
4174
|
dragStateRef.current = { kind: "idle" };
|