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.js
CHANGED
|
@@ -2599,20 +2599,25 @@ function markImageAsManaged(item) {
|
|
|
2599
2599
|
};
|
|
2600
2600
|
}
|
|
2601
2601
|
function restackManagedImages(items) {
|
|
2602
|
-
let
|
|
2602
|
+
let anchorAabbY = Infinity;
|
|
2603
|
+
let anchorCenterX = 0;
|
|
2603
2604
|
for (const item of items) {
|
|
2604
2605
|
if (!isManagedImage(item)) continue;
|
|
2605
|
-
|
|
2606
|
+
const aabb = boundsAabbForRotatedItem(item);
|
|
2607
|
+
if (aabb.y < anchorAabbY) {
|
|
2608
|
+
anchorAabbY = aabb.y;
|
|
2609
|
+
anchorCenterX = aabb.x + aabb.width / 2;
|
|
2610
|
+
}
|
|
2606
2611
|
}
|
|
2607
|
-
if (!
|
|
2608
|
-
|
|
2609
|
-
const anchorTopY = anchor.bounds.y;
|
|
2610
|
-
let cursorY = anchorTopY;
|
|
2612
|
+
if (!Number.isFinite(anchorAabbY)) return [...items];
|
|
2613
|
+
let cursorY = anchorAabbY;
|
|
2611
2614
|
return items.map((item) => {
|
|
2612
2615
|
if (!isManagedImage(item)) return item;
|
|
2616
|
+
const aabb = boundsAabbForRotatedItem(item);
|
|
2617
|
+
const centerY = cursorY + aabb.height / 2;
|
|
2613
2618
|
const newX = anchorCenterX - item.bounds.width / 2;
|
|
2614
|
-
const newY =
|
|
2615
|
-
cursorY
|
|
2619
|
+
const newY = centerY - item.bounds.height / 2;
|
|
2620
|
+
cursorY += aabb.height + STACK_GAP_WORLD;
|
|
2616
2621
|
if (item.bounds.x === newX && item.bounds.y === newY) return item;
|
|
2617
2622
|
return {
|
|
2618
2623
|
...item,
|
|
@@ -2635,8 +2640,10 @@ function copyManagedImage(items, id) {
|
|
|
2635
2640
|
return restackManagedImages(inserted);
|
|
2636
2641
|
}
|
|
2637
2642
|
function rotateManagedImage(items, id) {
|
|
2638
|
-
return
|
|
2639
|
-
|
|
2643
|
+
return restackManagedImages(
|
|
2644
|
+
items.map(
|
|
2645
|
+
(i) => i.id === id ? { ...i, rotation: ((i.rotation ?? 0) + Math.PI / 2) % (Math.PI * 2) } : i
|
|
2646
|
+
)
|
|
2640
2647
|
);
|
|
2641
2648
|
}
|
|
2642
2649
|
function deleteManagedImage(items, id) {
|