labellife-design-tool 2.5.1 → 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/config.js +10 -3
- package/dist/cjs/config.js.map +1 -1
- package/dist/cjs/index.js +49 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/store.js.map +1 -1
- package/dist/cjs/side-panel/index.js +7 -2
- package/dist/cjs/side-panel/index.js.map +1 -1
- package/dist/cjs/side-panel/side-panel.js +7 -2
- 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/config.js +10 -3
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/index.js +49 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/store.js.map +1 -1
- package/dist/esm/side-panel/index.js +7 -2
- package/dist/esm/side-panel/index.js.map +1 -1
- package/dist/esm/side-panel/side-panel.js +7 -2
- 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
|
@@ -417,6 +417,35 @@ function coverFitSize(boxWidth, boxHeight, naturalWidth, naturalHeight) {
|
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
+
// Minimum axis-aligned (pre-rotation) box size that, once rotated by rotationDeg around
|
|
421
|
+
// its own center, still fully covers a boxWidth x boxHeight area. Used so "Fit to page"
|
|
422
|
+
// can keep an image's existing rotation instead of resetting it — the unrotated image is
|
|
423
|
+
// sized against this larger box instead of the page itself.
|
|
424
|
+
function rotatedCoverBox(boxWidth, boxHeight, rotationDeg) {
|
|
425
|
+
var rad = rotationDeg * Math.PI / 180;
|
|
426
|
+
var cos = Math.abs(Math.cos(rad));
|
|
427
|
+
var sin = Math.abs(Math.sin(rad));
|
|
428
|
+
return {
|
|
429
|
+
width: boxWidth * cos + boxHeight * sin,
|
|
430
|
+
height: boxWidth * sin + boxHeight * cos
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// Top-left (x, y) position such that a width x height rect, rotated by rotationDeg using
|
|
435
|
+
// Konva's convention (rotation pivots around (x, y), i.e. the rect's own pre-rotation
|
|
436
|
+
// top-left corner, not its center), ends up centered within a boxWidth x boxHeight area.
|
|
437
|
+
function centerRotatedPosition(boxWidth, boxHeight, width, height, rotationDeg) {
|
|
438
|
+
var rad = rotationDeg * Math.PI / 180;
|
|
439
|
+
var cos = Math.cos(rad);
|
|
440
|
+
var sin = Math.sin(rad);
|
|
441
|
+
var halfWidth = width / 2;
|
|
442
|
+
var halfHeight = height / 2;
|
|
443
|
+
return {
|
|
444
|
+
x: boxWidth / 2 - (halfWidth * cos - halfHeight * sin),
|
|
445
|
+
y: boxHeight / 2 - (halfWidth * sin + halfHeight * cos)
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
|
|
420
449
|
var SliderRow = function SliderRow(_ref) {
|
|
421
450
|
var label = _ref.label,
|
|
422
451
|
value = _ref.value,
|
|
@@ -1243,27 +1272,32 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
1243
1272
|
// smallest size that fully covers the page, centered. No crop is applied — if the
|
|
1244
1273
|
// aspect ratio doesn't match the page, the image simply overflows the page bounds
|
|
1245
1274
|
// on two sides (same as manually resizing it to cover), rather than permanently
|
|
1246
|
-
// cropping away image data.
|
|
1275
|
+
// cropping away image data. Existing rotation is kept as-is (not reset) — the fit is
|
|
1276
|
+
// computed against the larger box a rotated rect needs to still cover the (unrotated)
|
|
1277
|
+
// page, so a rotated image stays rotated and centered instead of flying off-canvas.
|
|
1278
|
+
var rotation = element.rotation || 0;
|
|
1247
1279
|
var updates = {
|
|
1248
1280
|
cropX: 0,
|
|
1249
1281
|
cropY: 0,
|
|
1250
1282
|
cropWidth: 1,
|
|
1251
1283
|
cropHeight: 1
|
|
1252
1284
|
};
|
|
1285
|
+
var required = rotatedCoverBox(store.width, store.height, rotation);
|
|
1253
1286
|
if (element._naturalWidth && element._naturalHeight) {
|
|
1254
|
-
var _coverFitSize = coverFitSize(
|
|
1287
|
+
var _coverFitSize = coverFitSize(required.width, required.height, element._naturalWidth, element._naturalHeight),
|
|
1255
1288
|
width = _coverFitSize.width,
|
|
1256
1289
|
height = _coverFitSize.height;
|
|
1257
1290
|
updates.width = width;
|
|
1258
1291
|
updates.height = height;
|
|
1259
|
-
updates.x = (store.width - width) / 2;
|
|
1260
|
-
updates.y = (store.height - height) / 2;
|
|
1261
1292
|
} else {
|
|
1262
|
-
updates.
|
|
1263
|
-
updates.
|
|
1264
|
-
updates.width = store.width;
|
|
1265
|
-
updates.height = store.height;
|
|
1293
|
+
updates.width = required.width;
|
|
1294
|
+
updates.height = required.height;
|
|
1266
1295
|
}
|
|
1296
|
+
var _centerRotatedPositio = centerRotatedPosition(store.width, store.height, updates.width, updates.height, rotation),
|
|
1297
|
+
x = _centerRotatedPositio.x,
|
|
1298
|
+
y = _centerRotatedPositio.y;
|
|
1299
|
+
updates.x = x;
|
|
1300
|
+
updates.y = y;
|
|
1267
1301
|
element.set(updates);
|
|
1268
1302
|
store.history.addUndoState();
|
|
1269
1303
|
};
|