canvu-react 0.3.34 → 0.3.36
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 +17 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -10
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +264 -97
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +264 -97
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2606,20 +2606,25 @@ function markImageAsManaged(item) {
|
|
|
2606
2606
|
};
|
|
2607
2607
|
}
|
|
2608
2608
|
function restackManagedImages(items) {
|
|
2609
|
-
let
|
|
2609
|
+
let anchorAabbY = Infinity;
|
|
2610
|
+
let anchorCenterX = 0;
|
|
2610
2611
|
for (const item of items) {
|
|
2611
2612
|
if (!isManagedImage(item)) continue;
|
|
2612
|
-
|
|
2613
|
+
const aabb = boundsAabbForRotatedItem(item);
|
|
2614
|
+
if (aabb.y < anchorAabbY) {
|
|
2615
|
+
anchorAabbY = aabb.y;
|
|
2616
|
+
anchorCenterX = aabb.x + aabb.width / 2;
|
|
2617
|
+
}
|
|
2613
2618
|
}
|
|
2614
|
-
if (!
|
|
2615
|
-
|
|
2616
|
-
const anchorTopY = anchor.bounds.y;
|
|
2617
|
-
let cursorY = anchorTopY;
|
|
2619
|
+
if (!Number.isFinite(anchorAabbY)) return [...items];
|
|
2620
|
+
let cursorY = anchorAabbY;
|
|
2618
2621
|
return items.map((item) => {
|
|
2619
2622
|
if (!isManagedImage(item)) return item;
|
|
2623
|
+
const aabb = boundsAabbForRotatedItem(item);
|
|
2624
|
+
const centerY = cursorY + aabb.height / 2;
|
|
2620
2625
|
const newX = anchorCenterX - item.bounds.width / 2;
|
|
2621
|
-
const newY =
|
|
2622
|
-
cursorY
|
|
2626
|
+
const newY = centerY - item.bounds.height / 2;
|
|
2627
|
+
cursorY += aabb.height + STACK_GAP_WORLD;
|
|
2623
2628
|
if (item.bounds.x === newX && item.bounds.y === newY) return item;
|
|
2624
2629
|
return {
|
|
2625
2630
|
...item,
|
|
@@ -2642,8 +2647,10 @@ function copyManagedImage(items, id) {
|
|
|
2642
2647
|
return restackManagedImages(inserted);
|
|
2643
2648
|
}
|
|
2644
2649
|
function rotateManagedImage(items, id) {
|
|
2645
|
-
return
|
|
2646
|
-
|
|
2650
|
+
return restackManagedImages(
|
|
2651
|
+
items.map(
|
|
2652
|
+
(i) => i.id === id ? { ...i, rotation: ((i.rotation ?? 0) + Math.PI / 2) % (Math.PI * 2) } : i
|
|
2653
|
+
)
|
|
2647
2654
|
);
|
|
2648
2655
|
}
|
|
2649
2656
|
function deleteManagedImage(items, id) {
|