@tmagic/stage 1.0.0-beta.4 → 1.0.0-beta.7
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.es.js +34 -22
- package/dist/tmagic-stage.es.js.map +1 -1
- package/dist/tmagic-stage.umd.js +34 -22
- package/dist/tmagic-stage.umd.js.map +1 -1
- package/dist/types/src/StageDragResize.d.ts +2 -2
- package/dist/types/src/StageMask.d.ts +1 -0
- package/package.json +3 -3
- package/src/StageCore.ts +1 -2
- package/src/StageDragResize.ts +2 -5
- package/src/StageMask.ts +36 -15
package/dist/tmagic-stage.umd.js
CHANGED
|
@@ -100,11 +100,11 @@
|
|
|
100
100
|
container;
|
|
101
101
|
target;
|
|
102
102
|
moveable;
|
|
103
|
+
horizontalGuidelines = [];
|
|
104
|
+
verticalGuidelines = [];
|
|
103
105
|
dragStatus = "end" /* END */;
|
|
104
106
|
elObserver;
|
|
105
107
|
ghostEl;
|
|
106
|
-
horizontalGuidelines = [];
|
|
107
|
-
verticalGuidelines = [];
|
|
108
108
|
mode = Mode.ABSOLUTE;
|
|
109
109
|
constructor(config) {
|
|
110
110
|
super();
|
|
@@ -332,9 +332,6 @@
|
|
|
332
332
|
resizable: true,
|
|
333
333
|
snappable: !isSortable,
|
|
334
334
|
snapGap: !isSortable,
|
|
335
|
-
snapElement: !isSortable,
|
|
336
|
-
snapVertical: !isSortable,
|
|
337
|
-
snapHorizontal: !isSortable,
|
|
338
335
|
snapCenter: !isSortable,
|
|
339
336
|
container: renderer.contentWindow?.document.body,
|
|
340
337
|
elementGuidelines: isSortable ? [] : await this.getSnapElements(this.target),
|
|
@@ -17690,8 +17687,8 @@
|
|
|
17690
17687
|
this.core = config.core;
|
|
17691
17688
|
const { config: coreConfig } = config.core;
|
|
17692
17689
|
this.canSelect = coreConfig.canSelect || ((el) => !!el.id);
|
|
17693
|
-
this.content.addEventListener("mousedown", this.mouseDownHandler
|
|
17694
|
-
this.content.addEventListener("contextmenu", this.contextmenuHandler
|
|
17690
|
+
this.content.addEventListener("mousedown", this.mouseDownHandler);
|
|
17691
|
+
this.content.addEventListener("contextmenu", this.contextmenuHandler);
|
|
17695
17692
|
this.wrapper.appendChild(this.content);
|
|
17696
17693
|
this.hGuides = this.createGuides("horizontal");
|
|
17697
17694
|
this.vGuides = this.createGuides("vertical");
|
|
@@ -17749,16 +17746,23 @@
|
|
|
17749
17746
|
});
|
|
17750
17747
|
}
|
|
17751
17748
|
showRule(show = true) {
|
|
17752
|
-
|
|
17753
|
-
|
|
17754
|
-
|
|
17755
|
-
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17759
|
-
|
|
17760
|
-
|
|
17761
|
-
|
|
17749
|
+
if (show) {
|
|
17750
|
+
this.hGuides.destroy();
|
|
17751
|
+
this.hGuides = this.createGuides("horizontal", this.core.dr.horizontalGuidelines);
|
|
17752
|
+
this.vGuides.destroy();
|
|
17753
|
+
this.vGuides = this.createGuides("vertical", this.core.dr.verticalGuidelines);
|
|
17754
|
+
} else {
|
|
17755
|
+
this.hGuides.setState({
|
|
17756
|
+
rulerStyle: {
|
|
17757
|
+
visibility: "hidden"
|
|
17758
|
+
}
|
|
17759
|
+
});
|
|
17760
|
+
this.vGuides.setState({
|
|
17761
|
+
rulerStyle: {
|
|
17762
|
+
visibility: "hidden"
|
|
17763
|
+
}
|
|
17764
|
+
});
|
|
17765
|
+
}
|
|
17762
17766
|
}
|
|
17763
17767
|
clearGuides() {
|
|
17764
17768
|
this.vGuides.setState({
|
|
@@ -17780,13 +17784,21 @@
|
|
|
17780
17784
|
if (event.target.className.indexOf("moveable-control") !== -1) {
|
|
17781
17785
|
return;
|
|
17782
17786
|
}
|
|
17787
|
+
this.content.addEventListener("mousemove", this.mouseMoveHandler);
|
|
17783
17788
|
this.select(event);
|
|
17784
17789
|
};
|
|
17785
17790
|
mouseUpHandler = () => {
|
|
17786
|
-
this.content
|
|
17791
|
+
this.content.removeEventListener("mousemove", this.mouseMoveHandler);
|
|
17792
|
+
this.content.removeEventListener("mouseup", this.mouseUpHandler);
|
|
17787
17793
|
this.emit("selected", this.target);
|
|
17788
17794
|
this.target = null;
|
|
17789
17795
|
};
|
|
17796
|
+
mouseMoveHandler = (event) => {
|
|
17797
|
+
if (event.buttons) {
|
|
17798
|
+
this.core.dr.moveable?.dragStart(event);
|
|
17799
|
+
}
|
|
17800
|
+
this.content.removeEventListener("mousemove", this.mouseMoveHandler);
|
|
17801
|
+
};
|
|
17790
17802
|
contextmenuHandler = async (event) => {
|
|
17791
17803
|
await this.select(event);
|
|
17792
17804
|
this.mouseUpHandler();
|
|
@@ -17812,7 +17824,7 @@
|
|
|
17812
17824
|
break;
|
|
17813
17825
|
this.emit("select", el, event);
|
|
17814
17826
|
this.target = el;
|
|
17815
|
-
this.content
|
|
17827
|
+
this.content.addEventListener("mouseup", this.mouseUpHandler);
|
|
17816
17828
|
break;
|
|
17817
17829
|
}
|
|
17818
17830
|
}
|
|
@@ -17824,8 +17836,9 @@
|
|
|
17824
17836
|
width: type === "horizontal" ? "100%" : "30px",
|
|
17825
17837
|
height: type === "horizontal" ? "30px" : "100%"
|
|
17826
17838
|
});
|
|
17827
|
-
createGuides = (type) => new Guides__default["default"](this.wrapper, {
|
|
17839
|
+
createGuides = (type, defaultGuides = []) => new Guides__default["default"](this.wrapper, {
|
|
17828
17840
|
type,
|
|
17841
|
+
defaultGuides,
|
|
17829
17842
|
displayDragPos: true,
|
|
17830
17843
|
backgroundColor: "#fff",
|
|
17831
17844
|
lineColor: "#000",
|
|
@@ -17922,9 +17935,8 @@
|
|
|
17922
17935
|
this.dr = new StageDragResize({ core: this, container: this.mask.content });
|
|
17923
17936
|
this.renderer.on("runtime-ready", (runtime) => this.emit("runtime-ready", runtime));
|
|
17924
17937
|
this.renderer.on("page-el-update", (el) => this.mask?.observe(el));
|
|
17925
|
-
this.mask.on("select", async (el
|
|
17938
|
+
this.mask.on("select", async (el) => {
|
|
17926
17939
|
await this.dr?.select(el);
|
|
17927
|
-
setTimeout(() => this.dr?.moveable?.dragStart(event));
|
|
17928
17940
|
});
|
|
17929
17941
|
this.mask.on("selected", (el) => {
|
|
17930
17942
|
this.select(el);
|