@tmagic/stage 1.0.0-rc.11 → 1.0.0-rc.12

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.
@@ -86,11 +86,6 @@
86
86
  return true;
87
87
  return getHost(targetUrl) === source;
88
88
  };
89
- const isAbsolute = (el) => {
90
- if (!el)
91
- return false;
92
- return getComputedStyle(el).position === "absolute";
93
- };
94
89
  const isRelative = (el) => {
95
90
  if (!el)
96
91
  return false;
@@ -131,15 +126,15 @@
131
126
  };
132
127
  const getScrollParent = (element, includeHidden = false) => {
133
128
  let style = getComputedStyle(element);
129
+ const excludeStaticParent = style.position === "absolute";
134
130
  const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
135
- if (isFixed(element))
131
+ if (style.position === "fixed")
136
132
  return null;
137
133
  for (let parent = element; parent.parentElement; ) {
138
134
  parent = parent.parentElement;
139
135
  style = getComputedStyle(parent);
140
- if (isAbsolute(element) && isStatic(element)) {
136
+ if (excludeStaticParent && style.position === "static")
141
137
  continue;
142
- }
143
138
  if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX))
144
139
  return parent;
145
140
  }
@@ -222,7 +217,7 @@
222
217
  if (!this.moveable)
223
218
  throw new Error("\u672A\u521D\u59CB\u5316moveable");
224
219
  if (!el)
225
- throw new Error("\u4E3A\u9009\u4E2D\u4EFB\u4F55\u8282\u70B9");
220
+ throw new Error("\u672A\u9009\u4E2D\u4EFB\u4F55\u8282\u70B9");
226
221
  this.target = el;
227
222
  this.init(el);
228
223
  Object.entries(this.moveableOptions).forEach(([key, value]) => {
@@ -297,7 +292,7 @@
297
292
  }
298
293
  bindResizeEvent() {
299
294
  if (!this.moveable)
300
- throw new Error("moveable \u4E3A\u521D\u59CB\u5316");
295
+ throw new Error("moveable \u672A\u521D\u59CB\u5316");
301
296
  const frame = {
302
297
  left: 0,
303
298
  top: 0
@@ -331,7 +326,7 @@
331
326
  }
332
327
  bindDragEvent() {
333
328
  if (!this.moveable)
334
- throw new Error("moveable \u4E3A\u521D\u59CB\u5316");
329
+ throw new Error("moveable \u672A\u521D\u59CB\u5316");
335
330
  const frame = {
336
331
  left: 0,
337
332
  top: 0
@@ -373,7 +368,7 @@
373
368
  }
374
369
  bindRotateEvent() {
375
370
  if (!this.moveable)
376
- throw new Error("moveable \u4E3A\u521D\u59CB\u5316");
371
+ throw new Error("moveable \u672A\u521D\u59CB\u5316");
377
372
  this.moveable.on("rotateStart", (e) => {
378
373
  this.dragStatus = "start" /* START */;
379
374
  this.moveableHelper?.onRotateStart(e);
@@ -397,7 +392,7 @@
397
392
  }
398
393
  bindScaleEvent() {
399
394
  if (!this.moveable)
400
- throw new Error("moveable \u4E3A\u521D\u59CB\u5316");
395
+ throw new Error("moveable \u672A\u521D\u59CB\u5316");
401
396
  this.moveable.on("scaleStart", (e) => {
402
397
  this.dragStatus = "start" /* START */;
403
398
  this.moveableHelper?.onScaleStart(e);
@@ -1084,6 +1079,9 @@
1084
1079
  }
1085
1080
  }
1086
1081
  this.emit("onload");
1082
+ this.contentWindow.postMessage({
1083
+ tmagicRuntimeReady: true
1084
+ }, "*");
1087
1085
  };
1088
1086
  this.core = core;
1089
1087
  this.runtimeUrl = core.config.runtimeUrl || "";
@@ -1250,10 +1248,10 @@
1250
1248
  setZoom(zoom = DEFAULT_ZOOM) {
1251
1249
  this.zoom = zoom;
1252
1250
  }
1253
- mount(el) {
1251
+ async mount(el) {
1254
1252
  this.container = el;
1255
1253
  const { mask, renderer } = this;
1256
- renderer.mount(el);
1254
+ await renderer.mount(el);
1257
1255
  mask.mount(el);
1258
1256
  this.emit("mounted");
1259
1257
  }