@tmagic/stage 1.3.8 → 1.3.9

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.
@@ -70,7 +70,7 @@
70
70
  };
71
71
  const getTargetElStyle = (el, zIndex) => {
72
72
  const offset = getOffset(el);
73
- const { transform } = getComputedStyle(el);
73
+ const { transform, border } = getComputedStyle(el);
74
74
  return `
75
75
  position: absolute;
76
76
  transform: ${transform};
@@ -78,6 +78,7 @@
78
78
  top: ${offset.top}px;
79
79
  width: ${el.clientWidth}px;
80
80
  height: ${el.clientHeight}px;
81
+ border: ${border};
81
82
  ${typeof zIndex !== "undefined" ? `z-index: ${zIndex};` : ""}
82
83
  `;
83
84
  };
@@ -228,6 +229,22 @@
228
229
  marginTop: marginTopValue
229
230
  };
230
231
  };
232
+ const getBorderWidth = (el) => {
233
+ if (!el)
234
+ return {
235
+ borderLeftWidth: 0,
236
+ borderRightWidth: 0,
237
+ borderTopWidth: 0,
238
+ borderBottomWidth: 0
239
+ };
240
+ const { borderLeftWidth, borderRightWidth, borderTopWidth, borderBottomWidth } = getComputedStyle(el);
241
+ return {
242
+ borderLeftWidth: parseFloat(borderLeftWidth) || 0,
243
+ borderRightWidth: parseFloat(borderRightWidth) || 0,
244
+ borderTopWidth: parseFloat(borderTopWidth) || 0,
245
+ borderBottomWidth: parseFloat(borderBottomWidth) || 0
246
+ };
247
+ };
231
248
 
232
249
  class TargetShadow {
233
250
  el;
@@ -379,10 +396,11 @@
379
396
  this.moveableHelper.onResize(e);
380
397
  const { marginLeft, marginTop } = getMarginValue(this.target);
381
398
  this.target.style.left = `${this.frameSnapShot.left + beforeTranslate[0] - marginLeft}px`;
382
- this.target.style.top = `${this.frameSnapShot.top + beforeTranslate[1] - marginTop} - marginToppx`;
399
+ this.target.style.top = `${this.frameSnapShot.top + beforeTranslate[1] - marginTop}px`;
383
400
  }
384
- this.target.style.width = `${width}px`;
385
- this.target.style.height = `${height}px`;
401
+ const { borderLeftWidth, borderRightWidth, borderTopWidth, borderBottomWidth } = getBorderWidth(this.target);
402
+ this.target.style.width = `${width + borderLeftWidth + borderRightWidth}px`;
403
+ this.target.style.height = `${height + borderTopWidth + borderBottomWidth}px`;
386
404
  }
387
405
  onDragStart(e) {
388
406
  this.moveableHelper.onDragStart(e);
@@ -511,8 +529,9 @@
511
529
  const { marginLeft, marginTop } = getMarginValue(el);
512
530
  let left = calcValueByFontsize(doc, offset.left) - marginLeft;
513
531
  let top = calcValueByFontsize(doc, offset.top) - marginTop;
514
- const width = calcValueByFontsize(doc, el.clientWidth);
515
- const height = calcValueByFontsize(doc, el.clientHeight);
532
+ const { borderLeftWidth, borderRightWidth, borderTopWidth, borderBottomWidth } = getBorderWidth(el);
533
+ const width = calcValueByFontsize(doc, el.clientWidth + borderLeftWidth + borderRightWidth);
534
+ const height = calcValueByFontsize(doc, el.clientHeight + borderTopWidth + borderBottomWidth);
516
535
  let shadowEl = this.getShadowEl();
517
536
  const shadowEls = this.getShadowEls();
518
537
  if (shadowEls.length) {
@@ -1288,7 +1307,7 @@
1288
1307
  }).on("clickGroup", (e) => {
1289
1308
  const { inputTarget, targets } = e;
1290
1309
  if (targets.length > 1 && targets.includes(inputTarget)) {
1291
- this.emit("change-to-select", inputTarget.id.replace(DRAG_EL_ID_PREFIX, ""));
1310
+ this.emit("change-to-select", inputTarget.id.replace(DRAG_EL_ID_PREFIX, ""), e.inputEvent);
1292
1311
  }
1293
1312
  });
1294
1313
  }
@@ -1681,11 +1700,11 @@
1681
1700
  });
1682
1701
  multiDr?.on("update", (data) => {
1683
1702
  this.emit("multi-update", data);
1684
- }).on("change-to-select", async (id) => {
1703
+ }).on("change-to-select", async (id, e) => {
1685
1704
  if (this.isMultiSelectStatus)
1686
1705
  return false;
1687
1706
  const el = this.getTargetElement(id);
1688
- this.emit("change-to-select", el);
1707
+ this.emit("change-to-select", el, e);
1689
1708
  });
1690
1709
  return multiDr;
1691
1710
  }
@@ -2674,9 +2693,9 @@
2674
2693
  * 初始化MultiDragResize类通过ActionManager抛出来的事件监听
2675
2694
  */
2676
2695
  initMulDrEvent() {
2677
- this.actionManager.on("change-to-select", (el) => {
2696
+ this.actionManager.on("change-to-select", (el, e) => {
2678
2697
  this.select(el);
2679
- setTimeout(() => this.emit("select", el));
2698
+ setTimeout(() => this.emit("select", el, e));
2680
2699
  }).on("multi-update", (data) => {
2681
2700
  this.emit("update", data);
2682
2701
  });
@@ -2727,6 +2746,7 @@
2727
2746
  exports.default = StageCore;
2728
2747
  exports.down = down;
2729
2748
  exports.getAbsolutePosition = getAbsolutePosition;
2749
+ exports.getBorderWidth = getBorderWidth;
2730
2750
  exports.getMarginValue = getMarginValue;
2731
2751
  exports.getMode = getMode;
2732
2752
  exports.getOffset = getOffset;