@urso/core 0.4.41 → 0.4.42

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.4.41",
3
+ "version": "0.4.42",
4
4
  "description": "HTML5 game engine",
5
5
  "main": "build/js/index.js",
6
6
  "author": "Megbrimef",
@@ -101,6 +101,22 @@ class ModulesObjectsProxy {
101
101
  if (!target.maxWidth && !target.maxHeight)
102
102
  return;
103
103
 
104
+ let calculationNeed = false;
105
+
106
+ const baseObject = target._baseObject;
107
+ //Pixi texts have _texture.orig.width. When we call baseObject.width, Pixi runs update text. Its too slow operation.
108
+ const baseObjectWidth = baseObject._texture ? Math.abs(baseObject.scale.x) * baseObject._texture.orig.width : baseObject.width;
109
+ const baseObjectHeight = baseObject._texture ? Math.abs(baseObject.scale.y) * baseObject._texture.orig.height : baseObject.height;
110
+
111
+ if (target.maxWidth && target.maxWidth < baseObjectWidth) //check maxWidth
112
+ calculationNeed = true;
113
+
114
+ if (target.maxHeight && target.maxHeight < baseObjectHeight) //check maxHeight
115
+ calculationNeed = true;
116
+
117
+ if (!calculationNeed)
118
+ return;
119
+
104
120
  let scaleNeed = 1;
105
121
 
106
122
  if (target.maxWidth) {
@@ -42,7 +42,6 @@ class ModulesObjectsStyles {
42
42
  delete this._cache[selector];
43
43
  }
44
44
  }
45
-
46
45
  }
47
46
 
48
47
  _apply(selector, style) {
@@ -68,7 +67,7 @@ class ModulesObjectsStyles {
68
67
  _globalResetStyles() {
69
68
  for (let [selector, selectorCache] of Object.entries(this._cache)) {
70
69
  for (let [uid, object] of Object.entries(selectorCache))
71
- this._removeSelectorStyles(object, selector);
70
+ this._removeSelectorStyles(object, selector, true);
72
71
 
73
72
  delete this._cache[selector];
74
73
  }
@@ -84,7 +83,7 @@ class ModulesObjectsStyles {
84
83
  }
85
84
  }
86
85
 
87
- _removeSelectorStyles(object, selector) {
86
+ _removeSelectorStyles(object, selector, globalResetFlag) {
88
87
  delete object._styles[selector];
89
88
  let template = Urso.template.get();
90
89
  let styles = template.styles[selector];
@@ -94,12 +93,12 @@ class ModulesObjectsStyles {
94
93
  }
95
94
 
96
95
  for (let [key, value] of Object.entries(styles)) {
97
- this._restoreValueByKey(key, object);
96
+ this._restoreValueByKey(key, object, globalResetFlag);
98
97
  }
99
98
 
100
99
  }
101
100
 
102
- _restoreValueByKey(key, object) {
101
+ _restoreValueByKey(key, object, globalResetFlag) {
103
102
  //check own
104
103
  if (object._originalModel[key])
105
104
  return;
@@ -110,9 +109,11 @@ class ModulesObjectsStyles {
110
109
  Urso.objects._safeSetValueToTarget(object, key, tempObject[key]);
111
110
 
112
111
  //check other styles
113
- for (let [selector, style] of Object.entries(object._styles))
114
- if (typeof style[key] !== 'undefined')
115
- Urso.objects._safeSetValueToTarget(object, key, style[key]);
112
+ if (!globalResetFlag) {
113
+ for (let [selector, style] of Object.entries(object._styles))
114
+ if (typeof style[key] !== 'undefined')
115
+ Urso.objects._safeSetValueToTarget(object, key, style[key]);
116
+ }
116
117
  }
117
118
  }
118
119