labellife-design-tool 2.5.2 → 2.5.3
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/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +42 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/store.js.map +1 -1
- package/dist/cjs/side-panel/index.js.map +1 -1
- package/dist/cjs/side-panel/side-panel.js.map +1 -1
- package/dist/cjs/toolbar/toolbar.js +42 -8
- package/dist/cjs/toolbar/toolbar.js.map +1 -1
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +42 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/store.js.map +1 -1
- package/dist/esm/side-panel/index.js.map +1 -1
- package/dist/esm/side-panel/side-panel.js.map +1 -1
- package/dist/esm/toolbar/toolbar.js +42 -8
- package/dist/esm/toolbar/toolbar.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -653,6 +653,35 @@ function coverFitSize(boxWidth, boxHeight, naturalWidth, naturalHeight) {
|
|
|
653
653
|
};
|
|
654
654
|
}
|
|
655
655
|
|
|
656
|
+
// Minimum axis-aligned (pre-rotation) box size that, once rotated by rotationDeg around
|
|
657
|
+
// its own center, still fully covers a boxWidth x boxHeight area. Used so "Fit to page"
|
|
658
|
+
// can keep an image's existing rotation instead of resetting it — the unrotated image is
|
|
659
|
+
// sized against this larger box instead of the page itself.
|
|
660
|
+
function rotatedCoverBox(boxWidth, boxHeight, rotationDeg) {
|
|
661
|
+
var rad = rotationDeg * Math.PI / 180;
|
|
662
|
+
var cos = Math.abs(Math.cos(rad));
|
|
663
|
+
var sin = Math.abs(Math.sin(rad));
|
|
664
|
+
return {
|
|
665
|
+
width: boxWidth * cos + boxHeight * sin,
|
|
666
|
+
height: boxWidth * sin + boxHeight * cos
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// Top-left (x, y) position such that a width x height rect, rotated by rotationDeg using
|
|
671
|
+
// Konva's convention (rotation pivots around (x, y), i.e. the rect's own pre-rotation
|
|
672
|
+
// top-left corner, not its center), ends up centered within a boxWidth x boxHeight area.
|
|
673
|
+
function centerRotatedPosition(boxWidth, boxHeight, width, height, rotationDeg) {
|
|
674
|
+
var rad = rotationDeg * Math.PI / 180;
|
|
675
|
+
var cos = Math.cos(rad);
|
|
676
|
+
var sin = Math.sin(rad);
|
|
677
|
+
var halfWidth = width / 2;
|
|
678
|
+
var halfHeight = height / 2;
|
|
679
|
+
return {
|
|
680
|
+
x: boxWidth / 2 - (halfWidth * cos - halfHeight * sin),
|
|
681
|
+
y: boxHeight / 2 - (halfWidth * sin + halfHeight * cos)
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
|
|
656
685
|
// Cover-fit crop fractions (centered) for a box of given size over an image of natural size.
|
|
657
686
|
// Mirrors the existing auto-crop calculation in canvas/image-element.js.
|
|
658
687
|
function coverFitCrop(boxWidth, boxHeight, naturalWidth, naturalHeight) {
|
|
@@ -9391,27 +9420,32 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
9391
9420
|
// smallest size that fully covers the page, centered. No crop is applied — if the
|
|
9392
9421
|
// aspect ratio doesn't match the page, the image simply overflows the page bounds
|
|
9393
9422
|
// on two sides (same as manually resizing it to cover), rather than permanently
|
|
9394
|
-
// cropping away image data.
|
|
9423
|
+
// cropping away image data. Existing rotation is kept as-is (not reset) — the fit is
|
|
9424
|
+
// computed against the larger box a rotated rect needs to still cover the (unrotated)
|
|
9425
|
+
// page, so a rotated image stays rotated and centered instead of flying off-canvas.
|
|
9426
|
+
var rotation = element.rotation || 0;
|
|
9395
9427
|
var updates = {
|
|
9396
9428
|
cropX: 0,
|
|
9397
9429
|
cropY: 0,
|
|
9398
9430
|
cropWidth: 1,
|
|
9399
9431
|
cropHeight: 1
|
|
9400
9432
|
};
|
|
9433
|
+
var required = rotatedCoverBox(store.width, store.height, rotation);
|
|
9401
9434
|
if (element._naturalWidth && element._naturalHeight) {
|
|
9402
|
-
var _coverFitSize = coverFitSize(
|
|
9435
|
+
var _coverFitSize = coverFitSize(required.width, required.height, element._naturalWidth, element._naturalHeight),
|
|
9403
9436
|
width = _coverFitSize.width,
|
|
9404
9437
|
height = _coverFitSize.height;
|
|
9405
9438
|
updates.width = width;
|
|
9406
9439
|
updates.height = height;
|
|
9407
|
-
updates.x = (store.width - width) / 2;
|
|
9408
|
-
updates.y = (store.height - height) / 2;
|
|
9409
9440
|
} else {
|
|
9410
|
-
updates.
|
|
9411
|
-
updates.
|
|
9412
|
-
updates.width = store.width;
|
|
9413
|
-
updates.height = store.height;
|
|
9441
|
+
updates.width = required.width;
|
|
9442
|
+
updates.height = required.height;
|
|
9414
9443
|
}
|
|
9444
|
+
var _centerRotatedPositio = centerRotatedPosition(store.width, store.height, updates.width, updates.height, rotation),
|
|
9445
|
+
x = _centerRotatedPositio.x,
|
|
9446
|
+
y = _centerRotatedPositio.y;
|
|
9447
|
+
updates.x = x;
|
|
9448
|
+
updates.y = y;
|
|
9415
9449
|
element.set(updates);
|
|
9416
9450
|
store.history.addUndoState();
|
|
9417
9451
|
};
|