@urso/core 0.4.20 → 0.4.21
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
|
@@ -37,6 +37,8 @@ class ModulesObjectsBaseModel {
|
|
|
37
37
|
this.alignY = Urso.helper.recursiveGet('alignY', params, 'top'); //or bottom or center
|
|
38
38
|
this.width = Urso.helper.recursiveGet('width', params, false); //or 40% or 1456 // highest priority then scale
|
|
39
39
|
this.height = Urso.helper.recursiveGet('height', params, false); //or 40% or 568 // highest priority then scale
|
|
40
|
+
this.maxWidth = Urso.helper.recursiveGet('maxWidth', params, false); //maximum width value. If objects width will be higher, it will be downscale. Do not use with scale.
|
|
41
|
+
this.maxHeight = Urso.helper.recursiveGet('maxHeight', params, false); //maximum height value. If objects height will be higher, it will be downscale. Do not use with scale.
|
|
40
42
|
this.stretchingType = Urso.helper.recursiveGet('stretchingType', params, false); //or inscribed or circumscribed //works only if width=height=100%
|
|
41
43
|
this.angle = Urso.helper.recursiveGet('angle', params, 0);
|
|
42
44
|
this.visible = Urso.helper.recursiveGet('visible', params, true);
|
|
@@ -30,8 +30,6 @@ class ModulesObjectsModelsText extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
30
30
|
this.dropShadowDistance = Urso.helper.recursiveGet('dropShadowBlur', params, 0); // 6
|
|
31
31
|
this.wordWrap = Urso.helper.recursiveGet('wordWrap', params, false);
|
|
32
32
|
this.wordWrapWidth = Urso.helper.recursiveGet('wordWrapWidth', params, 100)
|
|
33
|
-
|
|
34
|
-
this.maxWidth = Urso.helper.recursiveGet('maxWidth', params, false); //todo
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
_addBaseObject() {
|
|
@@ -85,6 +85,8 @@ class ModulesObjectsProxy {
|
|
|
85
85
|
|
|
86
86
|
this._setProperty(target, propertyName, value);
|
|
87
87
|
|
|
88
|
+
this._checkMaxSize(target);
|
|
89
|
+
|
|
88
90
|
//setup dirty to recalc params
|
|
89
91
|
if (typeof target._baseObject.dirty !== 'undefined')
|
|
90
92
|
target._baseObject.dirty = true;
|
|
@@ -92,6 +94,30 @@ class ModulesObjectsProxy {
|
|
|
92
94
|
return true;
|
|
93
95
|
};
|
|
94
96
|
|
|
97
|
+
_checkMaxSize(target) {
|
|
98
|
+
if (!target.maxWidth && !target.maxHeight)
|
|
99
|
+
return;
|
|
100
|
+
|
|
101
|
+
let scaleNeed = 1;
|
|
102
|
+
|
|
103
|
+
if (target.maxWidth) {
|
|
104
|
+
scaleNeed = Math.abs((target._baseObject.scale.x * target.maxWidth) / target._baseObject.width);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (target.maxHeight) {
|
|
108
|
+
const scaleYNeed = Math.abs((target._baseObject.scale.y * target.maxHeight) / target._baseObject.height);
|
|
109
|
+
|
|
110
|
+
if (scaleNeed > scaleYNeed)
|
|
111
|
+
scaleNeed = scaleYNeed;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (scaleNeed > 1)
|
|
115
|
+
scaleNeed = 1;
|
|
116
|
+
|
|
117
|
+
target._baseObject.scale.x = scaleNeed * Math.sign(target._baseObject.scale.x);
|
|
118
|
+
target._baseObject.scale.y = scaleNeed * Math.sign(target._baseObject.scale.y);
|
|
119
|
+
}
|
|
120
|
+
|
|
95
121
|
_runCustomFunction(property, target) {
|
|
96
122
|
const funcName = property.replace('function.', '');
|
|
97
123
|
if (target[funcName])
|