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