canvu-react 0.4.21 → 0.4.22

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
@@ -3836,6 +3836,19 @@ function hitTestNativeSelectionHandle({
3836
3836
  );
3837
3837
  return handle ? { kind: "resize", handle } : null;
3838
3838
  }
3839
+ function pointInNativeSelectedItemBounds(item, worldPoint) {
3840
+ const bounds = normalizeRect(item.bounds);
3841
+ const local = worldToItemLocal(
3842
+ worldPoint.x,
3843
+ worldPoint.y,
3844
+ item.x,
3845
+ item.y,
3846
+ bounds.width,
3847
+ bounds.height,
3848
+ item.rotation ?? 0
3849
+ );
3850
+ return local.x >= 0 && local.x <= bounds.width && local.y >= 0 && local.y <= bounds.height;
3851
+ }
3839
3852
  function resolveNativeCustomPlacement(toolId, customPlacement, customPlacements) {
3840
3853
  if (customPlacement?.toolId === toolId) return customPlacement;
3841
3854
  return customPlacements?.find((placement) => placement.toolId === toolId) ?? null;
@@ -4160,6 +4173,25 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
4160
4173
  onSelectionChangeRef.current?.([hit.id]);
4161
4174
  }
4162
4175
  } else {
4176
+ const selectedUnlockedItems = currentSelectedIds.map((id) => itemsRef.current.find((item) => item.id === id)).filter((item) => !!item && !item.locked);
4177
+ if (selectedUnlockedItems.some(
4178
+ (item) => pointInNativeSelectedItemBounds(item, { x: worldX, y: worldY })
4179
+ )) {
4180
+ const snapshots = {};
4181
+ for (const item of selectedUnlockedItems) {
4182
+ snapshots[item.id] = item;
4183
+ }
4184
+ const ids = Object.keys(snapshots);
4185
+ if (ids.length > 0) {
4186
+ dragStateRef.current = {
4187
+ kind: "move",
4188
+ ids,
4189
+ snapshots,
4190
+ startWorld: { x: worldX, y: worldY }
4191
+ };
4192
+ return;
4193
+ }
4194
+ }
4163
4195
  onSelectionChangeRef.current?.([]);
4164
4196
  dragStateRef.current = {
4165
4197
  kind: "marquee",