@urso/core 0.7.12 → 0.7.13

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@urso/core",
3
- "version": "0.7.12",
3
+ "version": "0.7.13",
4
4
  "description": "HTML5 game engine",
5
5
  "main": "build/js/index.js",
6
6
  "author": "Megbrimef",
@@ -34,6 +34,34 @@ class LibHelper {
34
34
  return $_GET[name];
35
35
  }
36
36
 
37
+ /**
38
+ * waiter for dom element on page
39
+ * @param {String} selector
40
+ * @returns {Promice}
41
+ *
42
+ * @example
43
+ * waitForDomElement(.game-container).then(()=>{...})
44
+ */
45
+ waitForDomElement(selector) {
46
+ return new Promise(resolve => {
47
+ if (document.querySelector(selector)) {
48
+ return resolve(document.querySelector(selector));
49
+ }
50
+
51
+ const observer = new MutationObserver(mutations => {
52
+ if (document.querySelector(selector)) {
53
+ resolve(document.querySelector(selector));
54
+ observer.disconnect();
55
+ }
56
+ });
57
+
58
+ observer.observe(document.body, {
59
+ childList: true,
60
+ subtree: true
61
+ });
62
+ });
63
+ }
64
+
37
65
  /**
38
66
  * get uniq elements from two arrays
39
67
  * @param {Array} array1