canvu-react 0.4.21 → 0.4.23
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 +33 -2
- package/dist/native.cjs.map +1 -1
- package/dist/native.js +33 -2
- package/dist/native.js.map +1 -1
- package/package.json +1 -1
package/dist/native.js
CHANGED
|
@@ -1304,14 +1304,13 @@ function skiaCameraTransform(zoom, panX, panY) {
|
|
|
1304
1304
|
return [{ translateX: panX }, { translateY: panY }, { scale: zoom }];
|
|
1305
1305
|
}
|
|
1306
1306
|
function skiaItemPlacementTransform(x, y, cx, cy, rotationRad) {
|
|
1307
|
-
const result = [];
|
|
1307
|
+
const result = [{ translateX: x }, { translateY: y }];
|
|
1308
1308
|
if (Math.abs(rotationRad) > 1e-12) {
|
|
1309
1309
|
result.push({
|
|
1310
1310
|
rotate: rotationRad,
|
|
1311
1311
|
origin: { x: cx, y: cy }
|
|
1312
1312
|
});
|
|
1313
1313
|
}
|
|
1314
|
-
result.push({ translateX: x }, { translateY: y });
|
|
1315
1314
|
return result;
|
|
1316
1315
|
}
|
|
1317
1316
|
function rgbaFromHexAndOpacity(hex, opacity) {
|
|
@@ -3830,6 +3829,19 @@ function hitTestNativeSelectionHandle({
|
|
|
3830
3829
|
);
|
|
3831
3830
|
return handle ? { kind: "resize", handle } : null;
|
|
3832
3831
|
}
|
|
3832
|
+
function pointInNativeSelectedItemBounds(item, worldPoint) {
|
|
3833
|
+
const bounds = normalizeRect(item.bounds);
|
|
3834
|
+
const local = worldToItemLocal(
|
|
3835
|
+
worldPoint.x,
|
|
3836
|
+
worldPoint.y,
|
|
3837
|
+
item.x,
|
|
3838
|
+
item.y,
|
|
3839
|
+
bounds.width,
|
|
3840
|
+
bounds.height,
|
|
3841
|
+
item.rotation ?? 0
|
|
3842
|
+
);
|
|
3843
|
+
return local.x >= 0 && local.x <= bounds.width && local.y >= 0 && local.y <= bounds.height;
|
|
3844
|
+
}
|
|
3833
3845
|
function resolveNativeCustomPlacement(toolId, customPlacement, customPlacements) {
|
|
3834
3846
|
if (customPlacement?.toolId === toolId) return customPlacement;
|
|
3835
3847
|
return customPlacements?.find((placement) => placement.toolId === toolId) ?? null;
|
|
@@ -4154,6 +4166,25 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
4154
4166
|
onSelectionChangeRef.current?.([hit.id]);
|
|
4155
4167
|
}
|
|
4156
4168
|
} else {
|
|
4169
|
+
const selectedUnlockedItems = currentSelectedIds.map((id) => itemsRef.current.find((item) => item.id === id)).filter((item) => !!item && !item.locked);
|
|
4170
|
+
if (selectedUnlockedItems.some(
|
|
4171
|
+
(item) => pointInNativeSelectedItemBounds(item, { x: worldX, y: worldY })
|
|
4172
|
+
)) {
|
|
4173
|
+
const snapshots = {};
|
|
4174
|
+
for (const item of selectedUnlockedItems) {
|
|
4175
|
+
snapshots[item.id] = item;
|
|
4176
|
+
}
|
|
4177
|
+
const ids = Object.keys(snapshots);
|
|
4178
|
+
if (ids.length > 0) {
|
|
4179
|
+
dragStateRef.current = {
|
|
4180
|
+
kind: "move",
|
|
4181
|
+
ids,
|
|
4182
|
+
snapshots,
|
|
4183
|
+
startWorld: { x: worldX, y: worldY }
|
|
4184
|
+
};
|
|
4185
|
+
return;
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4157
4188
|
onSelectionChangeRef.current?.([]);
|
|
4158
4189
|
dragStateRef.current = {
|
|
4159
4190
|
kind: "marquee",
|