@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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.0-beta.7",
2
+ "version": "1.3.0",
3
3
  "name": "@tmagic/stage",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -31,9 +31,9 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@scena/guides": "^0.29.2",
34
- "@tmagic/core": "1.3.0-beta.7",
35
- "@tmagic/schema": "1.3.0-beta.7",
36
- "@tmagic/utils": "1.3.0-beta.7",
34
+ "@tmagic/core": "1.3.0",
35
+ "@tmagic/schema": "1.3.0",
36
+ "@tmagic/utils": "1.3.0",
37
37
  "events": "^3.3.0",
38
38
  "keycon": "^1.4.0",
39
39
  "lodash-es": "^4.17.21",
package/src/Rule.ts CHANGED
@@ -21,9 +21,6 @@ export default class Rule extends EventEmitter {
21
21
  this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
22
22
  this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
23
23
 
24
- this.hGuides.on('changeGuides', this.hGuidesChangeGuidesHandler);
25
- this.vGuides.on('changeGuides', this.vGuidesChangeGuidesHandler);
26
-
27
24
  this.containerResizeObserver = new ResizeObserver(() => {
28
25
  this.vGuides.resize();
29
26
  this.hGuides.resize();
@@ -129,8 +126,8 @@ export default class Rule extends EventEmitter {
129
126
  height: type === GuidesType.HORIZONTAL ? '30px' : '100%',
130
127
  });
131
128
 
132
- private createGuides = (type: GuidesType, defaultGuides: number[] = []): Guides =>
133
- new Guides(this.container, {
129
+ private createGuides = (type: GuidesType, defaultGuides: number[] = []): Guides => {
130
+ const guides = new Guides(this.container, {
134
131
  type,
135
132
  defaultGuides,
136
133
  displayDragPos: true,
@@ -141,6 +138,18 @@ export default class Rule extends EventEmitter {
141
138
  showGuides: this.isShowGuides,
142
139
  });
143
140
 
141
+ const changEventHandler = {
142
+ [GuidesType.HORIZONTAL]: this.hGuidesChangeGuidesHandler,
143
+ [GuidesType.VERTICAL]: this.vGuidesChangeGuidesHandler,
144
+ }[type];
145
+
146
+ if (changEventHandler) {
147
+ guides.on('changeGuides', changEventHandler);
148
+ }
149
+
150
+ return guides;
151
+ };
152
+
144
153
  private hGuidesChangeGuidesHandler = (e: GuidesEvents['changeGuides']) => {
145
154
  this.horizontalGuidelines = e.guides;
146
155
  this.emit('change-guides', {