@tmagic/stage 1.3.0-beta.7 → 1.3.0

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.
@@ -1788,8 +1788,6 @@
1788
1788
  this.container = container;
1789
1789
  this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
1790
1790
  this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
1791
- this.hGuides.on("changeGuides", this.hGuidesChangeGuidesHandler);
1792
- this.vGuides.on("changeGuides", this.vGuidesChangeGuidesHandler);
1793
1791
  this.containerResizeObserver = new ResizeObserver(() => {
1794
1792
  this.vGuides.resize();
1795
1793
  this.hGuides.resize();
@@ -1876,16 +1874,26 @@
1876
1874
  width: type === GuidesType.HORIZONTAL ? "100%" : "30px",
1877
1875
  height: type === GuidesType.HORIZONTAL ? "30px" : "100%"
1878
1876
  });
1879
- createGuides = (type, defaultGuides = []) => new Guides(this.container, {
1880
- type,
1881
- defaultGuides,
1882
- displayDragPos: true,
1883
- backgroundColor: "#fff",
1884
- lineColor: "#000",
1885
- textColor: "#000",
1886
- style: this.getGuidesStyle(type),
1887
- showGuides: this.isShowGuides
1888
- });
1877
+ createGuides = (type, defaultGuides = []) => {
1878
+ const guides = new Guides(this.container, {
1879
+ type,
1880
+ defaultGuides,
1881
+ displayDragPos: true,
1882
+ backgroundColor: "#fff",
1883
+ lineColor: "#000",
1884
+ textColor: "#000",
1885
+ style: this.getGuidesStyle(type),
1886
+ showGuides: this.isShowGuides
1887
+ });
1888
+ const changEventHandler = {
1889
+ [GuidesType.HORIZONTAL]: this.hGuidesChangeGuidesHandler,
1890
+ [GuidesType.VERTICAL]: this.vGuidesChangeGuidesHandler
1891
+ }[type];
1892
+ if (changEventHandler) {
1893
+ guides.on("changeGuides", changEventHandler);
1894
+ }
1895
+ return guides;
1896
+ };
1889
1897
  hGuidesChangeGuidesHandler = (e) => {
1890
1898
  this.horizontalGuidelines = e.guides;
1891
1899
  this.emit("change-guides", {