labellife-design-tool 2.4.4 → 2.4.5
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 +30 -5
- package/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +146 -145
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/store.js +5 -0
- package/dist/cjs/model/store.js.map +1 -1
- package/dist/cjs/side-panel/index.js +67 -131
- package/dist/cjs/side-panel/index.js.map +1 -1
- package/dist/cjs/side-panel/side-panel.js +67 -131
- package/dist/cjs/side-panel/side-panel.js.map +1 -1
- package/dist/cjs/toolbar/toolbar.js +57 -13
- package/dist/cjs/toolbar/toolbar.js.map +1 -1
- package/dist/esm/canvas/workspace.js +30 -5
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +146 -145
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/store.js +5 -0
- package/dist/esm/model/store.js.map +1 -1
- package/dist/esm/side-panel/index.js +67 -131
- package/dist/esm/side-panel/index.js.map +1 -1
- package/dist/esm/side-panel/side-panel.js +67 -131
- package/dist/esm/side-panel/side-panel.js.map +1 -1
- package/dist/esm/toolbar/toolbar.js +57 -13
- package/dist/esm/toolbar/toolbar.js.map +1 -1
- package/package.json +1 -1
|
@@ -495,8 +495,10 @@ var ImageMaskPanel = mobxReactLite.observer(function (_ref) {
|
|
|
495
495
|
});
|
|
496
496
|
ImageMaskPanel.displayName = 'ImageMaskPanel';
|
|
497
497
|
|
|
498
|
-
// Cover-fit
|
|
499
|
-
//
|
|
498
|
+
// Cover-fit SIZE (no cropping) for an image of natural size over a box of given size.
|
|
499
|
+
// The image is scaled to the smallest size that fully covers the box, preserving aspect
|
|
500
|
+
// ratio — one dimension matches the box, the other is larger and overflows the box
|
|
501
|
+
// (centered overflow on both sides).
|
|
500
502
|
|
|
501
503
|
// Clamp an image page-space offset so the image still fully covers rect at the given scale.
|
|
502
504
|
function clampImageOffset(offset, scale, rect, naturalWidth, naturalHeight) {
|
|
@@ -705,7 +707,15 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
705
707
|
// Initialized on image load (cover-fit centered), then updated directionally on resize.
|
|
706
708
|
var autoCropRef = React.useRef(null);
|
|
707
709
|
var autoCropSrcRef = React.useRef(null); // tracks which image the crop was computed for
|
|
708
|
-
|
|
710
|
+
// Tracks the element size autoCropRef was last computed/updated for, so we can tell
|
|
711
|
+
// apart a size change made through the drag/transform handlers (which keep this in
|
|
712
|
+
// sync themselves via updateAutoCrop) from one made externally (e.g. a toolbar
|
|
713
|
+
// "Fit to page" action) — the latter needs a fresh cover-fit recompute, not a clamp
|
|
714
|
+
// of the now-unrelated old crop rect.
|
|
715
|
+
var autoCropSizeRef = React.useRef({
|
|
716
|
+
w: null,
|
|
717
|
+
h: null
|
|
718
|
+
});
|
|
709
719
|
React.useEffect(function () {
|
|
710
720
|
if (!element.src) {
|
|
711
721
|
setImage(null);
|
|
@@ -810,6 +820,10 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
810
820
|
w: cw,
|
|
811
821
|
h: ch
|
|
812
822
|
};
|
|
823
|
+
autoCropSizeRef.current = {
|
|
824
|
+
w: newW,
|
|
825
|
+
h: newH
|
|
826
|
+
};
|
|
813
827
|
};
|
|
814
828
|
|
|
815
829
|
// Live transform — reset scale, set node dimensions, update crop directionally
|
|
@@ -868,8 +882,11 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
868
882
|
// Crop calculations
|
|
869
883
|
var modelHasCrop = image && (element.cropX !== 0 || element.cropY !== 0 || element.cropWidth !== 1 || element.cropHeight !== 1);
|
|
870
884
|
|
|
871
|
-
// Initialize auto-crop when image changes
|
|
872
|
-
|
|
885
|
+
// Initialize/refresh auto-crop when the image changes, or when width/height changed
|
|
886
|
+
// externally — i.e. NOT through the drag/transform handlers, which call
|
|
887
|
+
// updateAutoCrop themselves and keep autoCropSizeRef in sync as they go.
|
|
888
|
+
var sizeChangedExternally = autoCropSizeRef.current.w !== null && (Math.abs(element.width - autoCropSizeRef.current.w) > 0.5 || Math.abs(element.height - autoCropSizeRef.current.h) > 0.5);
|
|
889
|
+
if (image && (image !== autoCropSrcRef.current || !modelHasCrop && sizeChangedExternally)) {
|
|
873
890
|
autoCropSrcRef.current = image;
|
|
874
891
|
if (!modelHasCrop) {
|
|
875
892
|
var natW = image.naturalWidth || image.width;
|
|
@@ -900,10 +917,18 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
900
917
|
} else {
|
|
901
918
|
autoCropRef.current = null;
|
|
902
919
|
}
|
|
920
|
+
autoCropSizeRef.current = {
|
|
921
|
+
w: element.width,
|
|
922
|
+
h: element.height
|
|
923
|
+
};
|
|
903
924
|
}
|
|
904
925
|
if (!image) {
|
|
905
926
|
autoCropSrcRef.current = null;
|
|
906
927
|
autoCropRef.current = null;
|
|
928
|
+
autoCropSizeRef.current = {
|
|
929
|
+
w: null,
|
|
930
|
+
h: null
|
|
931
|
+
};
|
|
907
932
|
}
|
|
908
933
|
var cropProps = {};
|
|
909
934
|
if (modelHasCrop) {
|