@tmagic/stage 1.4.9 → 1.4.11

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.
@@ -1848,6 +1848,7 @@ class ActionManager extends EventEmitter {
1848
1848
  };
1849
1849
  }
1850
1850
 
1851
+ const guidesClass = "tmagic-stage-guides";
1851
1852
  class Rule extends EventEmitter {
1852
1853
  hGuides;
1853
1854
  vGuides;
@@ -1912,9 +1913,8 @@ class Rule extends EventEmitter {
1912
1913
  */
1913
1914
  showRule(show = true) {
1914
1915
  if (show) {
1915
- this.hGuides.destroy();
1916
+ this.destroyGuides();
1916
1917
  this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
1917
- this.vGuides.destroy();
1918
1918
  this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
1919
1919
  } else {
1920
1920
  this.hGuides.setState({
@@ -1936,11 +1936,19 @@ class Rule extends EventEmitter {
1936
1936
  this.vGuides.scroll(scrollTop);
1937
1937
  }
1938
1938
  destroy() {
1939
+ this.destroyGuides();
1939
1940
  this.hGuides.off("changeGuides", this.hGuidesChangeGuidesHandler);
1940
1941
  this.vGuides.off("changeGuides", this.vGuidesChangeGuidesHandler);
1941
1942
  this.containerResizeObserver.disconnect();
1942
1943
  this.removeAllListeners();
1943
1944
  }
1945
+ destroyGuides() {
1946
+ this.hGuides.destroy();
1947
+ this.vGuides.destroy();
1948
+ this.container.querySelectorAll(`.${guidesClass}`).forEach((el) => {
1949
+ el.remove();
1950
+ });
1951
+ }
1944
1952
  getGuidesStyle = (type) => ({
1945
1953
  position: "fixed",
1946
1954
  zIndex: 1,
@@ -1954,6 +1962,7 @@ class Rule extends EventEmitter {
1954
1962
  type,
1955
1963
  defaultGuides,
1956
1964
  displayDragPos: true,
1965
+ className: guidesClass,
1957
1966
  backgroundColor: "#fff",
1958
1967
  lineColor: "#000",
1959
1968
  textColor: "#000",
@@ -2102,11 +2111,11 @@ class StageMask extends Rule {
2102
2111
  * 销毁实例
2103
2112
  */
2104
2113
  destroy() {
2114
+ super.destroy();
2105
2115
  this.content?.remove();
2106
2116
  this.page = null;
2107
2117
  this.pageScrollParent = null;
2108
2118
  this.wrapperResizeObserver?.disconnect();
2109
- super.destroy();
2110
2119
  }
2111
2120
  on(eventName, listener) {
2112
2121
  return super.on(eventName, listener);
@@ -1845,6 +1845,7 @@
1845
1845
  };
1846
1846
  }
1847
1847
 
1848
+ const guidesClass = "tmagic-stage-guides";
1848
1849
  class Rule extends EventEmitter {
1849
1850
  hGuides;
1850
1851
  vGuides;
@@ -1909,9 +1910,8 @@
1909
1910
  */
1910
1911
  showRule(show = true) {
1911
1912
  if (show) {
1912
- this.hGuides.destroy();
1913
+ this.destroyGuides();
1913
1914
  this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
1914
- this.vGuides.destroy();
1915
1915
  this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
1916
1916
  } else {
1917
1917
  this.hGuides.setState({
@@ -1933,11 +1933,19 @@
1933
1933
  this.vGuides.scroll(scrollTop);
1934
1934
  }
1935
1935
  destroy() {
1936
+ this.destroyGuides();
1936
1937
  this.hGuides.off("changeGuides", this.hGuidesChangeGuidesHandler);
1937
1938
  this.vGuides.off("changeGuides", this.vGuidesChangeGuidesHandler);
1938
1939
  this.containerResizeObserver.disconnect();
1939
1940
  this.removeAllListeners();
1940
1941
  }
1942
+ destroyGuides() {
1943
+ this.hGuides.destroy();
1944
+ this.vGuides.destroy();
1945
+ this.container.querySelectorAll(`.${guidesClass}`).forEach((el) => {
1946
+ el.remove();
1947
+ });
1948
+ }
1941
1949
  getGuidesStyle = (type) => ({
1942
1950
  position: "fixed",
1943
1951
  zIndex: 1,
@@ -1951,6 +1959,7 @@
1951
1959
  type,
1952
1960
  defaultGuides,
1953
1961
  displayDragPos: true,
1962
+ className: guidesClass,
1954
1963
  backgroundColor: "#fff",
1955
1964
  lineColor: "#000",
1956
1965
  textColor: "#000",
@@ -2099,11 +2108,11 @@
2099
2108
  * 销毁实例
2100
2109
  */
2101
2110
  destroy() {
2111
+ super.destroy();
2102
2112
  this.content?.remove();
2103
2113
  this.page = null;
2104
2114
  this.pageScrollParent = null;
2105
2115
  this.wrapperResizeObserver?.disconnect();
2106
- super.destroy();
2107
2116
  }
2108
2117
  on(eventName, listener) {
2109
2118
  return super.on(eventName, listener);
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.4.9",
2
+ "version": "1.4.11",
3
3
  "name": "@tmagic/stage",
4
4
  "type": "module",
5
5
  "main": "dist/tmagic-stage.umd.cjs",
@@ -44,9 +44,9 @@
44
44
  },
45
45
  "peerDependencies": {
46
46
  "typescript": "*",
47
- "@tmagic/core": "1.4.9",
48
- "@tmagic/schema": "1.4.9",
49
- "@tmagic/utils": "1.4.9"
47
+ "@tmagic/schema": "1.4.11",
48
+ "@tmagic/utils": "1.4.11",
49
+ "@tmagic/core": "1.4.11"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "typescript": {
package/src/Rule.ts CHANGED
@@ -5,6 +5,8 @@ import Guides, { type GuidesEvents, type GuidesOptions } from '@scena/guides';
5
5
  import { GuidesType } from './const';
6
6
  import type { RuleOptions } from './types';
7
7
 
8
+ const guidesClass = 'tmagic-stage-guides';
9
+
8
10
  export default class Rule extends EventEmitter {
9
11
  public hGuides: Guides;
10
12
  public vGuides: Guides;
@@ -84,12 +86,11 @@ export default class Rule extends EventEmitter {
84
86
  * @param show 是否显示
85
87
  */
86
88
  public showRule(show = true) {
87
- // 当尺子隐藏时发现大小变化,显示后会变形,所以这里做重新初始化处理
89
+ // 当尺子隐藏时发生大小变化,显示后会变形,所以这里做重新初始化处理
88
90
  if (show) {
89
- this.hGuides.destroy();
90
- this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
91
+ this.destroyGuides();
91
92
 
92
- this.vGuides.destroy();
93
+ this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
93
94
  this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
94
95
  } else {
95
96
  this.hGuides.setState({
@@ -115,12 +116,22 @@ export default class Rule extends EventEmitter {
115
116
  }
116
117
 
117
118
  public destroy(): void {
119
+ this.destroyGuides();
118
120
  this.hGuides.off('changeGuides', this.hGuidesChangeGuidesHandler);
119
121
  this.vGuides.off('changeGuides', this.vGuidesChangeGuidesHandler);
120
122
  this.containerResizeObserver.disconnect();
121
123
  this.removeAllListeners();
122
124
  }
123
125
 
126
+ public destroyGuides(): void {
127
+ this.hGuides.destroy();
128
+ this.vGuides.destroy();
129
+
130
+ this.container.querySelectorAll(`.${guidesClass}`).forEach((el) => {
131
+ el.remove();
132
+ });
133
+ }
134
+
124
135
  private getGuidesStyle = (type: GuidesType) => ({
125
136
  position: 'fixed',
126
137
  zIndex: 1,
@@ -135,6 +146,7 @@ export default class Rule extends EventEmitter {
135
146
  type,
136
147
  defaultGuides,
137
148
  displayDragPos: true,
149
+ className: guidesClass,
138
150
  backgroundColor: '#fff',
139
151
  lineColor: '#000',
140
152
  textColor: '#000',
package/src/StageMask.ts CHANGED
@@ -170,12 +170,12 @@ export default class StageMask extends Rule {
170
170
  * 销毁实例
171
171
  */
172
172
  public destroy(): void {
173
+ super.destroy();
174
+
173
175
  this.content?.remove();
174
176
  this.page = null;
175
177
  this.pageScrollParent = null;
176
178
  this.wrapperResizeObserver?.disconnect();
177
-
178
- super.destroy();
179
179
  }
180
180
 
181
181
  public on<Name extends keyof MaskEvents, Param extends MaskEvents[Name]>(
package/types/Rule.d.ts CHANGED
@@ -29,6 +29,7 @@ export default class Rule extends EventEmitter {
29
29
  showRule(show?: boolean): void;
30
30
  scrollRule(scrollTop: number): void;
31
31
  destroy(): void;
32
+ destroyGuides(): void;
32
33
  private getGuidesStyle;
33
34
  private createGuides;
34
35
  private hGuidesChangeGuidesHandler;