@leafer-in/editor 1.4.0 → 1.4.1

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/editor.cjs CHANGED
@@ -162,7 +162,7 @@ class Stroker extends draw.UI {
162
162
  }
163
163
  __decorate([
164
164
  targetAttr(onTarget$1)
165
- ], Stroker.prototype, "target", undefined);
165
+ ], Stroker.prototype, "target", void 0);
166
166
  function onTarget$1(stroker) {
167
167
  const value = stroker.target;
168
168
  stroker.list = value ? (value instanceof Array ? value : [value]) : [];
@@ -441,7 +441,7 @@ const { within } = draw.MathHelper;
441
441
  const EditDataHelper = {
442
442
  getScaleData(element, startBounds, direction, totalMove, lockRatio, around, flipable, scaleMode) {
443
443
  let align, origin = {}, scaleX = 1, scaleY = 1;
444
- const { boxBounds, widthRange, heightRange } = element;
444
+ const { boxBounds, widthRange, heightRange, dragBounds } = element;
445
445
  const { width, height } = startBounds;
446
446
  if (around) {
447
447
  totalMove.x *= 2;
@@ -529,6 +529,17 @@ const EditDataHelper = {
529
529
  if (scaleY < 0)
530
530
  scaleY = 1 / boxBounds.height / worldTransform.scaleY;
531
531
  }
532
+ toPoint(around || align, boxBounds, origin, true);
533
+ if (dragBounds) {
534
+ const allowBounds = dragBounds === 'parent' ? element.parent.boxBounds : dragBounds;
535
+ const localBounds = new draw.Bounds(element.__localBoxBounds);
536
+ localBounds.scaleOf(element.getLocalPointByInner(origin), scaleX, scaleY);
537
+ if (!draw.BoundsHelper.includes(allowBounds, localBounds)) {
538
+ const realBounds = localBounds.getIntersect(allowBounds);
539
+ scaleX *= realBounds.width / localBounds.width;
540
+ scaleY *= realBounds.height / localBounds.height;
541
+ }
542
+ }
532
543
  if (widthRange) {
533
544
  const nowWidth = boxBounds.width * element.scaleX;
534
545
  scaleX = within(nowWidth * scaleX, widthRange) / nowWidth;
@@ -537,7 +548,6 @@ const EditDataHelper = {
537
548
  const nowHeight = boxBounds.height * element.scaleY;
538
549
  scaleY = within(nowHeight * scaleY, heightRange) / nowHeight;
539
550
  }
540
- toPoint(around || align, boxBounds, origin, true);
541
551
  return { origin, scaleX, scaleY, direction, lockRatio, around };
542
552
  },
543
553
  getRotateData(bounds, direction, current, last, around) {
@@ -1441,9 +1451,9 @@ class Editor extends draw.Group {
1441
1451
  this.skewOf(origin, skewX, skewY);
1442
1452
  }
1443
1453
  move(x, y = 0) {
1454
+ const { element } = this;
1444
1455
  if (!this.checkTransform('moveable'))
1445
1456
  return;
1446
- const { element } = this;
1447
1457
  const world = element.getWorldPointByLocal(typeof x === 'object' ? Object.assign({}, x) : { x, y }, null, true);
1448
1458
  if (this.multiple)
1449
1459
  element.safeChange(() => element.move(x, y));
@@ -1651,10 +1661,10 @@ class Editor extends draw.Group {
1651
1661
  }
1652
1662
  __decorate([
1653
1663
  targetAttr(onHover)
1654
- ], Editor.prototype, "hoverTarget", undefined);
1664
+ ], Editor.prototype, "hoverTarget", void 0);
1655
1665
  __decorate([
1656
1666
  targetAttr(onTarget)
1657
- ], Editor.prototype, "target", undefined);
1667
+ ], Editor.prototype, "target", void 0);
1658
1668
 
1659
1669
  class InnerEditor {
1660
1670
  static registerInnerEditor() {