@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.
- package/dist/tmagic-stage.js +31 -12
- package/dist/tmagic-stage.js.map +1 -1
- package/dist/tmagic-stage.umd.cjs +31 -11
- package/dist/tmagic-stage.umd.cjs.map +1 -1
- package/package.json +4 -4
- package/src/ActionManager.ts +2 -2
- package/src/DragResizeHelper.ts +11 -6
- package/src/StageCore.ts +2 -2
- package/src/StageMultiDragResize.ts +1 -1
- package/src/util.ts +21 -1
- package/types/util.d.ts +6 -0
package/dist/tmagic-stage.js
CHANGED
|
@@ -73,7 +73,7 @@ const getOffset = (el) => {
|
|
|
73
73
|
};
|
|
74
74
|
const getTargetElStyle = (el, zIndex) => {
|
|
75
75
|
const offset = getOffset(el);
|
|
76
|
-
const { transform } = getComputedStyle(el);
|
|
76
|
+
const { transform, border } = getComputedStyle(el);
|
|
77
77
|
return `
|
|
78
78
|
position: absolute;
|
|
79
79
|
transform: ${transform};
|
|
@@ -81,6 +81,7 @@ const getTargetElStyle = (el, zIndex) => {
|
|
|
81
81
|
top: ${offset.top}px;
|
|
82
82
|
width: ${el.clientWidth}px;
|
|
83
83
|
height: ${el.clientHeight}px;
|
|
84
|
+
border: ${border};
|
|
84
85
|
${typeof zIndex !== "undefined" ? `z-index: ${zIndex};` : ""}
|
|
85
86
|
`;
|
|
86
87
|
};
|
|
@@ -231,6 +232,22 @@ const getMarginValue = (el) => {
|
|
|
231
232
|
marginTop: marginTopValue
|
|
232
233
|
};
|
|
233
234
|
};
|
|
235
|
+
const getBorderWidth = (el) => {
|
|
236
|
+
if (!el)
|
|
237
|
+
return {
|
|
238
|
+
borderLeftWidth: 0,
|
|
239
|
+
borderRightWidth: 0,
|
|
240
|
+
borderTopWidth: 0,
|
|
241
|
+
borderBottomWidth: 0
|
|
242
|
+
};
|
|
243
|
+
const { borderLeftWidth, borderRightWidth, borderTopWidth, borderBottomWidth } = getComputedStyle(el);
|
|
244
|
+
return {
|
|
245
|
+
borderLeftWidth: parseFloat(borderLeftWidth) || 0,
|
|
246
|
+
borderRightWidth: parseFloat(borderRightWidth) || 0,
|
|
247
|
+
borderTopWidth: parseFloat(borderTopWidth) || 0,
|
|
248
|
+
borderBottomWidth: parseFloat(borderBottomWidth) || 0
|
|
249
|
+
};
|
|
250
|
+
};
|
|
234
251
|
|
|
235
252
|
class TargetShadow {
|
|
236
253
|
el;
|
|
@@ -382,10 +399,11 @@ class DragResizeHelper {
|
|
|
382
399
|
this.moveableHelper.onResize(e);
|
|
383
400
|
const { marginLeft, marginTop } = getMarginValue(this.target);
|
|
384
401
|
this.target.style.left = `${this.frameSnapShot.left + beforeTranslate[0] - marginLeft}px`;
|
|
385
|
-
this.target.style.top = `${this.frameSnapShot.top + beforeTranslate[1] - marginTop}
|
|
402
|
+
this.target.style.top = `${this.frameSnapShot.top + beforeTranslate[1] - marginTop}px`;
|
|
386
403
|
}
|
|
387
|
-
this.target
|
|
388
|
-
this.target.style.
|
|
404
|
+
const { borderLeftWidth, borderRightWidth, borderTopWidth, borderBottomWidth } = getBorderWidth(this.target);
|
|
405
|
+
this.target.style.width = `${width + borderLeftWidth + borderRightWidth}px`;
|
|
406
|
+
this.target.style.height = `${height + borderTopWidth + borderBottomWidth}px`;
|
|
389
407
|
}
|
|
390
408
|
onDragStart(e) {
|
|
391
409
|
this.moveableHelper.onDragStart(e);
|
|
@@ -514,8 +532,9 @@ class DragResizeHelper {
|
|
|
514
532
|
const { marginLeft, marginTop } = getMarginValue(el);
|
|
515
533
|
let left = calcValueByFontsize(doc, offset.left) - marginLeft;
|
|
516
534
|
let top = calcValueByFontsize(doc, offset.top) - marginTop;
|
|
517
|
-
const
|
|
518
|
-
const
|
|
535
|
+
const { borderLeftWidth, borderRightWidth, borderTopWidth, borderBottomWidth } = getBorderWidth(el);
|
|
536
|
+
const width = calcValueByFontsize(doc, el.clientWidth + borderLeftWidth + borderRightWidth);
|
|
537
|
+
const height = calcValueByFontsize(doc, el.clientHeight + borderTopWidth + borderBottomWidth);
|
|
519
538
|
let shadowEl = this.getShadowEl();
|
|
520
539
|
const shadowEls = this.getShadowEls();
|
|
521
540
|
if (shadowEls.length) {
|
|
@@ -1291,7 +1310,7 @@ class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
1291
1310
|
}).on("clickGroup", (e) => {
|
|
1292
1311
|
const { inputTarget, targets } = e;
|
|
1293
1312
|
if (targets.length > 1 && targets.includes(inputTarget)) {
|
|
1294
|
-
this.emit("change-to-select", inputTarget.id.replace(DRAG_EL_ID_PREFIX, ""));
|
|
1313
|
+
this.emit("change-to-select", inputTarget.id.replace(DRAG_EL_ID_PREFIX, ""), e.inputEvent);
|
|
1295
1314
|
}
|
|
1296
1315
|
});
|
|
1297
1316
|
}
|
|
@@ -1684,11 +1703,11 @@ class ActionManager extends EventEmitter {
|
|
|
1684
1703
|
});
|
|
1685
1704
|
multiDr?.on("update", (data) => {
|
|
1686
1705
|
this.emit("multi-update", data);
|
|
1687
|
-
}).on("change-to-select", async (id) => {
|
|
1706
|
+
}).on("change-to-select", async (id, e) => {
|
|
1688
1707
|
if (this.isMultiSelectStatus)
|
|
1689
1708
|
return false;
|
|
1690
1709
|
const el = this.getTargetElement(id);
|
|
1691
|
-
this.emit("change-to-select", el);
|
|
1710
|
+
this.emit("change-to-select", el, e);
|
|
1692
1711
|
});
|
|
1693
1712
|
return multiDr;
|
|
1694
1713
|
}
|
|
@@ -2677,9 +2696,9 @@ class StageCore extends EventEmitter$1 {
|
|
|
2677
2696
|
* 初始化MultiDragResize类通过ActionManager抛出来的事件监听
|
|
2678
2697
|
*/
|
|
2679
2698
|
initMulDrEvent() {
|
|
2680
|
-
this.actionManager.on("change-to-select", (el) => {
|
|
2699
|
+
this.actionManager.on("change-to-select", (el, e) => {
|
|
2681
2700
|
this.select(el);
|
|
2682
|
-
setTimeout(() => this.emit("select", el));
|
|
2701
|
+
setTimeout(() => this.emit("select", el, e));
|
|
2683
2702
|
}).on("multi-update", (data) => {
|
|
2684
2703
|
this.emit("update", data);
|
|
2685
2704
|
});
|
|
@@ -2706,5 +2725,5 @@ class StageCore extends EventEmitter$1 {
|
|
|
2706
2725
|
}
|
|
2707
2726
|
}
|
|
2708
2727
|
|
|
2709
|
-
export { AbleActionEventType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, HIGHLIGHT_EL_ID_PREFIX, Mode, MouseButton, PAGE_CLASS, RenderType, SELECTED_CLASS, SelectStatus, StageDragResize, StageDragStatus, StageMask, StageRender, ZIndex, addSelectedClassName, calcValueByFontsize, StageCore as default, down, getAbsolutePosition, getMarginValue, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isMoveableButton, isRelative, isStatic, removeSelectedClassName, up };
|
|
2728
|
+
export { AbleActionEventType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, HIGHLIGHT_EL_ID_PREFIX, Mode, MouseButton, PAGE_CLASS, RenderType, SELECTED_CLASS, SelectStatus, StageDragResize, StageDragStatus, StageMask, StageRender, ZIndex, addSelectedClassName, calcValueByFontsize, StageCore as default, down, getAbsolutePosition, getBorderWidth, getMarginValue, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isMoveableButton, isRelative, isStatic, removeSelectedClassName, up };
|
|
2710
2729
|
//# sourceMappingURL=tmagic-stage.js.map
|