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 CHANGED
@@ -1310,14 +1310,13 @@ function skiaCameraTransform(zoom, panX, panY) {
1310
1310
  return [{ translateX: panX }, { translateY: panY }, { scale: zoom }];
1311
1311
  }
1312
1312
  function skiaItemPlacementTransform(x, y, cx, cy, rotationRad) {
1313
- const result = [];
1313
+ const result = [{ translateX: x }, { translateY: y }];
1314
1314
  if (Math.abs(rotationRad) > 1e-12) {
1315
1315
  result.push({
1316
1316
  rotate: rotationRad,
1317
1317
  origin: { x: cx, y: cy }
1318
1318
  });
1319
1319
  }
1320
- result.push({ translateX: x }, { translateY: y });
1321
1320
  return result;
1322
1321
  }
1323
1322
  function rgbaFromHexAndOpacity(hex, opacity) {
@@ -3836,6 +3835,19 @@ function hitTestNativeSelectionHandle({
3836
3835
  );
3837
3836
  return handle ? { kind: "resize", handle } : null;
3838
3837
  }
3838
+ function pointInNativeSelectedItemBounds(item, worldPoint) {
3839
+ const bounds = normalizeRect(item.bounds);
3840
+ const local = worldToItemLocal(
3841
+ worldPoint.x,
3842
+ worldPoint.y,
3843
+ item.x,
3844
+ item.y,
3845
+ bounds.width,
3846
+ bounds.height,
3847
+ item.rotation ?? 0
3848
+ );
3849
+ return local.x >= 0 && local.x <= bounds.width && local.y >= 0 && local.y <= bounds.height;
3850
+ }
3839
3851
  function resolveNativeCustomPlacement(toolId, customPlacement, customPlacements) {
3840
3852
  if (customPlacement?.toolId === toolId) return customPlacement;
3841
3853
  return customPlacements?.find((placement) => placement.toolId === toolId) ?? null;
@@ -4160,6 +4172,25 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
4160
4172
  onSelectionChangeRef.current?.([hit.id]);
4161
4173
  }
4162
4174
  } else {
4175
+ const selectedUnlockedItems = currentSelectedIds.map((id) => itemsRef.current.find((item) => item.id === id)).filter((item) => !!item && !item.locked);
4176
+ if (selectedUnlockedItems.some(
4177
+ (item) => pointInNativeSelectedItemBounds(item, { x: worldX, y: worldY })
4178
+ )) {
4179
+ const snapshots = {};
4180
+ for (const item of selectedUnlockedItems) {
4181
+ snapshots[item.id] = item;
4182
+ }
4183
+ const ids = Object.keys(snapshots);
4184
+ if (ids.length > 0) {
4185
+ dragStateRef.current = {
4186
+ kind: "move",
4187
+ ids,
4188
+ snapshots,
4189
+ startWorld: { x: worldX, y: worldY }
4190
+ };
4191
+ return;
4192
+ }
4193
+ }
4163
4194
  onSelectionChangeRef.current?.([]);
4164
4195
  dragStateRef.current = {
4165
4196
  kind: "marquee",