neo.mjs 8.9.0 → 8.9.1

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.
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='8.9.0'
23
+ * @member {String} version='8.9.1'
24
24
  */
25
- version: '8.9.0'
25
+ version: '8.9.1'
26
26
  }
27
27
 
28
28
  /**
@@ -107,7 +107,7 @@ class FooterContainer extends Container {
107
107
  }, {
108
108
  module: Component,
109
109
  cls : ['neo-version'],
110
- html : 'v8.9.0'
110
+ html : 'v8.9.1'
111
111
  }]
112
112
  }],
113
113
  /**
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='8.9.0'
23
+ * @member {String} version='8.9.1'
24
24
  */
25
- version: '8.9.0'
25
+ version: '8.9.1'
26
26
  }
27
27
 
28
28
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "8.9.0",
3
+ "version": "8.9.1",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -262,12 +262,12 @@ const DefaultConfig = {
262
262
  useVdomWorker: true,
263
263
  /**
264
264
  * buildScripts/injectPackageVersion.mjs will update this value
265
- * @default '8.9.0'
265
+ * @default '8.9.1'
266
266
  * @memberOf! module:Neo
267
267
  * @name config.version
268
268
  * @type String
269
269
  */
270
- version: '8.9.0'
270
+ version: '8.9.1'
271
271
  };
272
272
 
273
273
  Object.assign(DefaultConfig, {
@@ -1684,7 +1684,7 @@ class Component extends Base {
1684
1684
  * Convenience shortcut
1685
1685
  * @param {String[]|String} id=this.id
1686
1686
  * @param {String} appName=this.appName
1687
- * @returns {Promise<Neo.util.Rectangle>}
1687
+ * @returns {Promise<Neo.util.Rectangle||Neo.util.Rectangle[]>}
1688
1688
  */
1689
1689
  async getDomRect(id=this.id, appName=this.appName) {
1690
1690
  let result = await Neo.main.DomAccess.getBoundingClientRect({appName, id, windowId: this.windowId});
@@ -1696,6 +1696,42 @@ class Component extends Base {
1696
1696
  return Rectangle.clone(result)
1697
1697
  }
1698
1698
 
1699
+ /**
1700
+ * In case you are sure a DOMRect exists, use getDomRect()
1701
+ * Otherwise you can wait for it using this method.
1702
+ * @example:
1703
+ * await this.render(true);
1704
+ * await this.waitForDomRect();
1705
+ * @param {Object} opts
1706
+ * @param {String} opts.appName=this.appName
1707
+ * @param {Number} opts.attempts=10 Reruns in case the rect height or width equals 0
1708
+ * @param {Number} opts.delay=50 Time in ms before checking again
1709
+ * @param {String[]|String} opts.id=this.id
1710
+ * @returns {Promise<Neo.util.Rectangle||Neo.util.Rectangle[]>}
1711
+ */
1712
+ async waitForDomRect({appName=this.appName, attempts=10, delay=50, id=this.id}) {
1713
+ let me = this,
1714
+ result = await me.getDomRect(id, appName),
1715
+ reRun = false;
1716
+
1717
+ if (Array.isArray(result)) {
1718
+ result.forEach(rect => {
1719
+ if (rect.height < 1 || rect.width < 1) {
1720
+ reRun = true
1721
+ }
1722
+ })
1723
+ } else if (result.height < 1 || result.width < 1) {
1724
+ reRun = true
1725
+ }
1726
+
1727
+ if (reRun && attempts > 0) {
1728
+ await me.timeout(delay);
1729
+ return await me.waitForDomRect({appName, attempts: attempts-1, delay, id})
1730
+ }
1731
+
1732
+ return result
1733
+ }
1734
+
1699
1735
  /**
1700
1736
  * Honors different item roots for mount / render OPs
1701
1737
  * @returns {String}
@@ -411,11 +411,23 @@ class Dialog extends Panel {
411
411
 
412
412
  rect = await me.getDomRect(me.animateTargetId);
413
413
 
414
+ if (style.left || style.top) {
415
+ let tempStyle = {...style};
416
+
417
+ // Ensure that the initial mounting happens outside the visible area
418
+ delete style.left;
419
+ delete style.top;
420
+
421
+ me.style = style;
422
+
423
+ // Silent update & ensure that a given starting position won't get lost
424
+ me._style = style = tempStyle
425
+ }
426
+
414
427
  // rendered outside the visible area
415
428
  await me.render(true);
416
- await me.timeout(150);
417
429
 
418
- let [dialogRect, bodyRect] = await me.getDomRect([me.id, 'document.body']);
430
+ let [dialogRect, bodyRect] = await me.waitForDomRect({id: [me.id, 'document.body']});
419
431
 
420
432
  // Move to cover the animation target
421
433
  await Neo.applyDeltas(appName, {