@urso/core 0.6.15 → 0.6.16

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.
Files changed (156) hide show
  1. package/.babelrc +11 -11
  2. package/LICENSE +20 -20
  3. package/README.md +227 -227
  4. package/build/js/index.js +1 -1
  5. package/build/js/index.js.LICENSE.txt +38 -222
  6. package/package.json +52 -52
  7. package/src/js/app.js +79 -79
  8. package/src/js/components/_info.js +11 -11
  9. package/src/js/components/base/_info.js +3 -3
  10. package/src/js/components/base/controller.js +78 -78
  11. package/src/js/components/debug/_info.js +7 -7
  12. package/src/js/components/debug/controller.js +38 -38
  13. package/src/js/components/debug/coords.js +23 -23
  14. package/src/js/components/debug/fps.js +36 -36
  15. package/src/js/components/debug/template.js +55 -55
  16. package/src/js/components/debug/timescale.js +60 -60
  17. package/src/js/components/deviceRotate/_info.js +3 -3
  18. package/src/js/components/deviceRotate/controller.js +86 -86
  19. package/src/js/components/fullscreen/_info.js +6 -6
  20. package/src/js/components/fullscreen/android.js +104 -104
  21. package/src/js/components/fullscreen/controller.js +76 -76
  22. package/src/js/components/fullscreen/desktop.js +49 -49
  23. package/src/js/components/fullscreen/ios.js +115 -115
  24. package/src/js/components/layersSwitcher/_info.js +4 -4
  25. package/src/js/components/layersSwitcher/config.js +26 -26
  26. package/src/js/components/layersSwitcher/controller.js +34 -34
  27. package/src/js/components/loader/_info.js +4 -4
  28. package/src/js/components/loader/controller.js +65 -65
  29. package/src/js/components/loader/template.js +70 -70
  30. package/src/js/components/soundInitialPopup/_info.js +3 -3
  31. package/src/js/components/soundInitialPopup/controller.js +42 -42
  32. package/src/js/components/soundInitialPopup/template.js +109 -109
  33. package/src/js/components/stateDriven/_info.js +3 -3
  34. package/src/js/components/stateDriven/controller.js +118 -118
  35. package/src/js/config/load.js +5 -5
  36. package/src/js/config/main.js +16 -16
  37. package/src/js/extra/_info.js +26 -26
  38. package/src/js/extra/browserEvents.js +51 -51
  39. package/src/js/extra/pixiPatch.js +150 -150
  40. package/src/js/extra/setTimeout.js +7 -7
  41. package/src/js/index.js +8 -8
  42. package/src/js/lib/_info.js +13 -13
  43. package/src/js/lib/cache.js +105 -105
  44. package/src/js/lib/composition.js +85 -85
  45. package/src/js/lib/device.js +1286 -1286
  46. package/src/js/lib/helper.js +556 -556
  47. package/src/js/lib/loader.js +136 -136
  48. package/src/js/lib/localData.js +15 -15
  49. package/src/js/lib/logger.js +69 -69
  50. package/src/js/lib/math.js +35 -35
  51. package/src/js/lib/objectPool.js +203 -203
  52. package/src/js/lib/time.js +18 -18
  53. package/src/js/lib/tween.js +147 -147
  54. package/src/js/modules/_info.js +12 -12
  55. package/src/js/modules/assets/_info.js +7 -7
  56. package/src/js/modules/assets/baseModel.js +20 -20
  57. package/src/js/modules/assets/config.js +37 -37
  58. package/src/js/modules/assets/controller.js +46 -46
  59. package/src/js/modules/assets/models/_info.js +11 -11
  60. package/src/js/modules/assets/models/atlas.js +8 -8
  61. package/src/js/modules/assets/models/audiosprite.js +27 -27
  62. package/src/js/modules/assets/models/bitmapFont.js +8 -8
  63. package/src/js/modules/assets/models/container.js +16 -16
  64. package/src/js/modules/assets/models/font.js +8 -8
  65. package/src/js/modules/assets/models/image.js +15 -15
  66. package/src/js/modules/assets/models/json.js +8 -8
  67. package/src/js/modules/assets/models/sound.js +14 -14
  68. package/src/js/modules/assets/models/spine.js +14 -14
  69. package/src/js/modules/assets/service.js +366 -366
  70. package/src/js/modules/i18n/_info.js +4 -4
  71. package/src/js/modules/i18n/config.js +17 -17
  72. package/src/js/modules/i18n/controller.js +79 -79
  73. package/src/js/modules/instances/_info.js +3 -3
  74. package/src/js/modules/instances/controller.js +357 -357
  75. package/src/js/modules/logic/_info.js +4 -4
  76. package/src/js/modules/logic/config/_info.js +2 -2
  77. package/src/js/modules/logic/config/sounds.js +23 -23
  78. package/src/js/modules/logic/controller.js +48 -48
  79. package/src/js/modules/logic/sounds.js +103 -103
  80. package/src/js/modules/objects/_info.js +13 -13
  81. package/src/js/modules/objects/baseModel.js +200 -200
  82. package/src/js/modules/objects/cache.js +99 -99
  83. package/src/js/modules/objects/controller.js +131 -131
  84. package/src/js/modules/objects/find.js +58 -58
  85. package/src/js/modules/objects/models/_info.js +27 -27
  86. package/src/js/modules/objects/models/atlasImage.js +50 -50
  87. package/src/js/modules/objects/models/bitmapText.js +37 -37
  88. package/src/js/modules/objects/models/button.js +189 -189
  89. package/src/js/modules/objects/models/buttonComposite.js +35 -35
  90. package/src/js/modules/objects/models/checkbox.js +96 -96
  91. package/src/js/modules/objects/models/collection.js +54 -54
  92. package/src/js/modules/objects/models/component.js +46 -46
  93. package/src/js/modules/objects/models/container.js +19 -19
  94. package/src/js/modules/objects/models/dragContainer.js +667 -667
  95. package/src/js/modules/objects/models/emitter.js +67 -67
  96. package/src/js/modules/objects/models/emitterFx.js +99 -99
  97. package/src/js/modules/objects/models/graphics.js +38 -38
  98. package/src/js/modules/objects/models/group.js +19 -19
  99. package/src/js/modules/objects/models/hitArea.js +104 -104
  100. package/src/js/modules/objects/models/image.js +34 -34
  101. package/src/js/modules/objects/models/imagesAnimation.js +113 -113
  102. package/src/js/modules/objects/models/mask.js +38 -38
  103. package/src/js/modules/objects/models/nineSlicePlane.js +30 -30
  104. package/src/js/modules/objects/models/scrollbox.js +64 -64
  105. package/src/js/modules/objects/models/slider.js +253 -253
  106. package/src/js/modules/objects/models/spine.js +296 -287
  107. package/src/js/modules/objects/models/text.js +59 -59
  108. package/src/js/modules/objects/models/textInput.js +66 -66
  109. package/src/js/modules/objects/models/toggle.js +180 -180
  110. package/src/js/modules/objects/models/world.js +19 -19
  111. package/src/js/modules/objects/propertyAdapter.js +588 -587
  112. package/src/js/modules/objects/proxy.js +294 -294
  113. package/src/js/modules/objects/selector.js +136 -136
  114. package/src/js/modules/objects/service.js +242 -242
  115. package/src/js/modules/objects/styles.js +210 -210
  116. package/src/js/modules/observer/_info.js +4 -4
  117. package/src/js/modules/observer/controller.js +99 -99
  118. package/src/js/modules/observer/events.js +52 -52
  119. package/src/js/modules/scenes/_info.js +8 -8
  120. package/src/js/modules/scenes/controller.js +119 -119
  121. package/src/js/modules/scenes/model.js +28 -28
  122. package/src/js/modules/scenes/pixiWrapper.js +336 -336
  123. package/src/js/modules/scenes/resolutions.js +173 -173
  124. package/src/js/modules/scenes/resolutionsConfig.js +73 -73
  125. package/src/js/modules/scenes/service.js +142 -142
  126. package/src/js/modules/soundManager/_info.js +3 -3
  127. package/src/js/modules/soundManager/controller.js +100 -100
  128. package/src/js/modules/soundManager/soundSprite.js +251 -251
  129. package/src/js/modules/statesManager/_info.js +12 -12
  130. package/src/js/modules/statesManager/action.js +68 -68
  131. package/src/js/modules/statesManager/actions/_info.js +3 -3
  132. package/src/js/modules/statesManager/all.js +23 -23
  133. package/src/js/modules/statesManager/configStates.js +71 -71
  134. package/src/js/modules/statesManager/controller.js +170 -170
  135. package/src/js/modules/statesManager/functionsStorage.js +82 -82
  136. package/src/js/modules/statesManager/helper.js +27 -27
  137. package/src/js/modules/statesManager/race.js +75 -75
  138. package/src/js/modules/statesManager/sequence.js +47 -47
  139. package/src/js/modules/template/_info.js +6 -6
  140. package/src/js/modules/template/controller.js +28 -28
  141. package/src/js/modules/template/model.js +11 -11
  142. package/src/js/modules/template/service.js +137 -137
  143. package/src/js/modules/template/types.js +46 -46
  144. package/src/js/modules/transport/_info.js +8 -8
  145. package/src/js/modules/transport/baseConnectionType.js +24 -24
  146. package/src/js/modules/transport/config.js +13 -13
  147. package/src/js/modules/transport/connectionTypes/_info.js +3 -3
  148. package/src/js/modules/transport/connectionTypes/websocket.js +74 -74
  149. package/src/js/modules/transport/connectionTypes/xhr.js +44 -44
  150. package/src/js/modules/transport/controller.js +48 -48
  151. package/src/js/modules/transport/decorator.js +17 -17
  152. package/src/js/modules/transport/service.js +153 -153
  153. package/src/js/templates/_info.js +4 -4
  154. package/src/js/templates/groups/_info.js +1 -1
  155. package/src/js/templates/scenes/_info.js +1 -1
  156. package/webpack.config.js +47 -47
@@ -1,588 +1,589 @@
1
- /**
2
- * adapter Urso to Pixi objects
3
- */
4
- class PropertyAdapter {
5
-
6
- constructor() {
7
- this.singleton = true;
8
-
9
- /**
10
- * dependencies, functions to handle changing property
11
- */
12
- this._dependencies = {
13
- 'x': this._updateHorizontal.bind(this),
14
- 'y': this._updateVertical.bind(this),
15
- 'anchorX': this._updateHorizontal.bind(this),
16
- 'anchorY': this._updateVertical.bind(this),
17
- 'scaleX': this._adaptScaleX.bind(this),
18
- 'scaleY': this._adaptScaleY.bind(this),
19
- 'alignX': this._updateHorizontal.bind(this),
20
- 'alignY': this._updateVertical.bind(this),
21
- 'width': this._updateHorizontal.bind(this),
22
- 'height': this._updateVertical.bind(this),
23
- 'angle': this._updateAngle.bind(this),
24
- 'stretchingType': this._adaptStretchingType.bind(this), //todo check on parent change
25
- 'parent': this._parentChangeHandler.bind(this)
26
- };
27
-
28
- /**
29
- * functions to handle changing parent property
30
- */
31
- this._parentToChildDependencies = {
32
- 'width': { children: ['width'] },
33
- 'height': { children: ['height'] },
34
- 'anchorX': { children: ['x'] },
35
- 'anchorY': { children: ['y'] },
36
- 'stretchingType': { children: ['width', 'height'] }
37
- };
38
-
39
- /**
40
- * parent types list
41
- */
42
- this._parentTypes = [
43
- Urso.types.objects.COMPONENT,
44
- Urso.types.objects.CONTAINER,
45
- Urso.types.objects.DRAGCONTAINER,
46
- Urso.types.objects.GROUP,
47
- Urso.types.objects.SCROLLBOX,
48
- Urso.types.objects.SLIDER,
49
- Urso.types.objects.WORLD
50
- ];
51
-
52
- /**
53
- * types without ahchor list
54
- */
55
- this._typesWithoutAnchor = [
56
- Urso.types.objects.CHECKBOX,
57
- Urso.types.objects.EMITTER,
58
- Urso.types.objects.EMITTERFX,
59
- Urso.types.objects.GRAPHICS,
60
- Urso.types.objects.HITAREA,
61
- Urso.types.objects.MASK,
62
- Urso.types.objects.NINESLICEPLANE,
63
- Urso.types.objects.SLIDER,
64
- Urso.types.objects.SPINE,
65
- Urso.types.objects.TEXTINPUT,
66
- Urso.types.objects.WORLD
67
- ];
68
- }
69
-
70
- /**
71
- * check is adaptive property
72
- * @param {String} property
73
- * @returns {Boolean}
74
- */
75
- isAdaptiveProperty(property) {
76
- return Object.keys(this._dependencies).includes(property);
77
- };
78
-
79
- /**
80
- * property change handler (main function)
81
- * @param {Object} object
82
- * @param {String} propertyName
83
- */
84
- propertyChangeHandler(object, propertyName) {
85
- this._adaptProperty(object, propertyName);
86
- this._adaptChildProperties(object, propertyName);
87
- }
88
-
89
- /**
90
- * adapt property (launch handler changing property)
91
- * @param {Object} object
92
- * @param {String} propertyName
93
- */
94
- _adaptProperty(object, propertyName) {
95
- if (this._dependencies[propertyName])
96
- this._dependencies[propertyName](object);
97
- }
98
-
99
- /**
100
- * main function to calculate x and width
101
- * @param {Object} object
102
- */
103
- _updateHorizontal(object) {
104
- let x = this._getXAsNumber(object);
105
- x += this._adaptAnchorX(object);
106
- x += this._adaptAlignX(object);
107
- object._baseObject.x = x;
108
-
109
- this._adaptWidth(object);
110
- }
111
-
112
- /**
113
- * main function to calculate angle
114
- * @param {Object} object
115
- */
116
- _updateAngle(object) {
117
- object._baseObject.angle = object.angle;
118
-
119
- if (!this._canBeParent(object)) {
120
- return;
121
- }
122
-
123
- this._updateHorizontal(object);
124
- this._updateVertical(object);
125
- }
126
-
127
- /**
128
- * main function to calculate y and height
129
- * @param {Object} object
130
- */
131
- _updateVertical(object) {
132
- let y = this._getYAsNumber(object);
133
- y += this._adaptAnchorY(object);
134
- y += this._adaptAlignY(object);
135
- object._baseObject.y = y;
136
-
137
- this._adaptHeight(object);
138
- }
139
-
140
- /**
141
- * set property value without adaptation
142
- * @param {Object} object
143
- * @param {String} propertyName
144
- * @param {mixed} value
145
- */
146
- _setPropertyWithoutAdaption(object, propertyName, value) { //in error case
147
- object[propertyName] = value;
148
- }
149
-
150
- /**
151
- * adapt child properties if parent properties was changed
152
- * @param {Object} object
153
- * @param {String} propertyName
154
- */
155
- _adaptChildProperties(object, propertyName) {
156
- const { children } = this._parentToChildDependencies[propertyName] || {};
157
- const objectHasChildren = this._canBeParent(object) && object.hasOwnProperty('contents');
158
-
159
- if (!children || !objectHasChildren)
160
- return;
161
-
162
- for (let dependency of children)
163
- for (let child of object.contents)
164
- this.propertyChangeHandler(child, dependency);
165
- }
166
-
167
- /**
168
- * main handler when new parent was setted
169
- * @param {Object} child
170
- */
171
- _parentChangeHandler(child) {
172
- if (child.parent == null)
173
- return;
174
-
175
- for (let propertyName of this._propertiesDependentOnParent())
176
- this.propertyChangeHandler(child, propertyName);
177
- }
178
-
179
- /**
180
- * get array of properties dependent on parent
181
- * //todo cache them and get just one time
182
- * @returns {Array}
183
- */
184
- _propertiesDependentOnParent() {
185
- const properties = [];
186
-
187
- for (let propertyName of Object.keys(this._parentToChildDependencies)) {
188
- const { children } = this._parentToChildDependencies[propertyName];
189
-
190
- if (children)
191
- for (let dependency of children)
192
- properties.push(dependency);
193
- }
194
-
195
- return properties;
196
- }
197
-
198
- /**
199
- * adapt anchorX
200
- * @param {Object} object
201
- */
202
- _adaptAnchorX(object) {
203
- if (typeof object.anchorX !== 'number' || object.anchorX < 0 || object.anchorX > 1)
204
- Urso.logger.error('AnchorX value is not valid!', object);
205
-
206
- if (this._canBeParent(object)) { //parent types
207
- if (object.anchorX === 0)
208
- return 0;
209
-
210
- if (object.angle) {
211
- return this._getAnchorOffsetByAngle(object, 'x');
212
- }
213
-
214
- const objectWidth = this._getWidthAsNumber(object);
215
- return - objectWidth * object.anchorX;
216
- } else if (!this._typesWithoutAnchor.includes(object.type)) { //regular type and not a type without anchor
217
- const pixiObject = object._baseObject;
218
- pixiObject.anchor.x = object.anchorX;
219
- } else {
220
- Urso.logger.warn(); ('AnchorX value cannot be used with this object type !', object);
221
- }
222
-
223
- return 0;
224
- }
225
-
226
- /**
227
- * adapt anchorY
228
- * @param {Object} object
229
- */
230
- _adaptAnchorY(object) {
231
- if (typeof object.anchorY !== 'number' || object.anchorY < 0 || object.anchorY > 1)
232
- Urso.logger.error('AnchorY value is not valid!', object);
233
-
234
- if (this._canBeParent(object)) { //parent types
235
- if (object.anchorY === 0)
236
- return 0;
237
-
238
- if (object.angle) {
239
- return this._getAnchorOffsetByAngle(object, 'y');
240
- }
241
-
242
- const objectHeight = this._getHeightAsNumber(object);
243
- return - objectHeight * object.anchorY;
244
- } else if (!this._typesWithoutAnchor.includes(object.type)) { //regular type and not a type without anchor
245
- const pixiObject = object._baseObject;
246
- pixiObject.anchor.y = object.anchorY;
247
- } else {
248
- Urso.logger.warn(); ('AnchorY value cannot be used with this object type !', object);
249
- }
250
-
251
- return 0;
252
- }
253
-
254
- /**
255
- * get anchor offset by angle for parent types
256
- * @param {Object} object
257
- * @param {String} side - x or y
258
- * @returns {Number}
259
- */
260
- _getAnchorOffsetByAngle(object, side) { //side can be x or y
261
- const objectWidth = this._getWidthAsNumber(object);
262
- const objectHeight = this._getHeightAsNumber(object);
263
- const xCatet = (objectWidth * object.anchorX);
264
- const yCatet = (objectHeight * object.anchorY);
265
- const offsetRadius = Math.sqrt(Math.pow(xCatet, 2) + Math.pow(yCatet, 2));
266
- const angleRadian = Math.atan(xCatet / yCatet); //todo or yCatet/xCatet ?
267
- const angle = Urso.helper.getAngle(angleRadian);
268
- const offsetAngle = object.angle + angle;
269
- const offsetFunction = side === 'x' ? 'cos' : 'sin';
270
- const angleOffset = - offsetRadius * Math[offsetFunction](Urso.helper.getRadian(offsetAngle));
271
-
272
- return angleOffset;
273
- }
274
-
275
- /**
276
- * adapt scaleX
277
- * @param {Object} object
278
- */
279
- _adaptScaleX(object) {
280
- if (object.scaleX !== 1 && typeof object.width !== 'boolean') {
281
- Urso.logger.error('ScaleX value cannot be set. Width already used!!');
282
- this._setPropertyWithoutAdaption(object, 'scaleX', 1);
283
- return;
284
- }
285
-
286
- if (typeof object.scaleX === 'number') {
287
- const pixiObject = object._baseObject;
288
- pixiObject.scale.x = object.scaleX;
289
- } else
290
- Urso.logger.error('ScaleX value is not valid!');
291
- }
292
-
293
- /**
294
- * adapt scaleY
295
- * @param {Object} object
296
- */
297
- _adaptScaleY(object) {
298
- if (object.scaleY !== 1 && typeof object.height !== 'boolean') {
299
- Urso.logger.error('ScaleY value cannot be set. Height already used!!');
300
- this._setPropertyWithoutAdaption(object, 'scaleY', 1);
301
- return;
302
- }
303
-
304
- if (typeof object.scaleY === 'number' && object.scaleY >= 0) { // TODO: CHECK SCALE CAN BE NEGATIVE
305
- const pixiObject = object._baseObject;
306
- pixiObject.scale.y = object.scaleY;
307
- } else
308
- Urso.logger.error('ScaleY value is not valid!');
309
- }
310
-
311
- /**
312
- * adapt alignX
313
- * @param {Object} object
314
- */
315
- _adaptAlignX(object) {
316
- if (typeof object.alignX !== 'string') {
317
- Urso.logger.error('AlignX value is not string!');
318
- return 0;
319
- }
320
-
321
- switch (object.alignX) {
322
- case 'left':
323
- return 0;
324
- case 'right':
325
- return object.parent ? this._getWidthAsNumber(object.parent) : 0; //parentWidth
326
- case 'center':
327
- const parentWidth = object.parent ? this._getWidthAsNumber(object.parent) : 0;
328
- return parentWidth / 2;
329
- default:
330
- Urso.logger.error('AlignX string is not valid!');
331
- return 0;
332
- }
333
- }
334
-
335
- /**
336
- * adapt alignY
337
- * @param {Object} object
338
- */
339
- _adaptAlignY(object) {
340
- if (typeof object.alignY !== 'string') {
341
- Urso.logger.error('AlignY value is not string!');
342
- return 0;
343
- }
344
-
345
- switch (object.alignY) {
346
- case 'top':
347
- return 0;
348
- case 'bottom':
349
- return object.parent ? this._getHeightAsNumber(object.parent) : 0; //parentHeight
350
- case 'center':
351
- const parentHeight = object.parent ? this._getHeightAsNumber(object.parent) : 0;
352
- return parentHeight / 2;
353
- default:
354
- Urso.logger.error('AlignY string is not valid!');
355
- return 0;
356
- }
357
- }
358
-
359
- /**
360
- * adapt width
361
- * @param {Object} object
362
- */
363
- _adaptWidth(object) {
364
- if (typeof object.width !== 'boolean' && object.scaleX !== 1) {
365
- Urso.logger.error('Width value cannot be set. ScaleX already used!!', object);
366
- this._setPropertyWithoutAdaption(object, 'width', false);
367
- return;
368
- }
369
-
370
- if (!object.width)
371
- return;
372
-
373
- if (!this._isValueANumberOrPercentsString(object.width))
374
- return Urso.logger.error('Width value is not valid!!');
375
-
376
- if (!this._canBeParent(object)) {
377
- const pixiObject = object._baseObject;
378
- pixiObject.width = this._getWidthAsNumber(object);
379
- }
380
- }
381
-
382
- /**
383
- * adapt height
384
- * @param {Object} object
385
- */
386
- _adaptHeight(object) {
387
- if (typeof object.height !== 'boolean' && object.scaleY !== 1) {
388
- Urso.logger.error('Height value cannot be set. ScaleY already used!!', object);
389
- this._setPropertyWithoutAdaption(object, 'height', false);
390
- return;
391
- }
392
-
393
- if (!object.height)
394
- return;
395
-
396
- if (!this._isValueANumberOrPercentsString(object.height))
397
- return Urso.logger.error('Height value not valid!');
398
-
399
- if (!this._canBeParent(object)) {
400
- const pixiObject = object._baseObject;
401
- pixiObject.height = this._getHeightAsNumber(object);
402
- }
403
- }
404
-
405
- /**
406
- * get x number value
407
- * @param {Object} object
408
- * @returns {Number}
409
- */
410
- _getXAsNumber(object) {
411
- return this._getPropertyAsNumber(object, 'x', 'width');
412
- }
413
-
414
- /**
415
- * get y number value
416
- * @param {Object} object
417
- * @returns {Number}
418
- */
419
- _getYAsNumber(object) {
420
- return this._getPropertyAsNumber(object, 'y', 'height');
421
- }
422
-
423
- /**
424
- * get width number value
425
- * @param {Object} object
426
- * @returns {Number}
427
- */
428
- _getWidthAsNumber(object) {
429
- return this._getPropertyAsNumber(object, 'width', 'width');
430
- }
431
-
432
- /**
433
- * get height number value
434
- * @param {Object} object
435
- * @returns {Number}
436
- */
437
- _getHeightAsNumber(object) {
438
- return this._getPropertyAsNumber(object, 'height', 'height');
439
- }
440
-
441
- /**
442
- * get x, y, width or height number value
443
- * @param {Object} object
444
- * @param {String} propertyName
445
- * @param {String} parentPropertyName
446
- * @returns {Number}
447
- */
448
- _getPropertyAsNumber(object, propertyName, parentPropertyName) {
449
- const propType = typeof object[propertyName];
450
-
451
- switch (propType) {
452
- case 'number':
453
- return object[propertyName];
454
-
455
- case 'string':
456
- const parentValue = this._getPropertyAsNumber(object.parent, parentPropertyName, parentPropertyName);
457
- return this._getRoundedPercentageOfNumber(object[propertyName], parentValue);
458
-
459
- case 'boolean':
460
- return this._getPropertyAsNumber(object.parent, propertyName, parentPropertyName)
461
-
462
- default:
463
- Urso.logger.error('Property value not number or string!', object, propertyName);
464
- return;
465
- }
466
- }
467
-
468
- /**
469
- * get rounded persents of number
470
- * @param {String} percentsString
471
- * @param {Number} number
472
- * @returns {Number}
473
- */
474
- _getRoundedPercentageOfNumber(percentsString, number) {
475
- const percentsFloat = parseFloat(percentsString);
476
- return ~~(percentsFloat * number / 100);
477
- }
478
-
479
- /**
480
- * check can be object a parent (by type)
481
- * @param {Object} object
482
- * @returns {Boolean}
483
- */
484
- _canBeParent(object) {
485
- return this._parentTypes.includes(object.type);
486
- }
487
-
488
- /**
489
- * check is value a number or a percents string
490
- * @param {mixed} value
491
- * @returns {Boolean}
492
- */
493
- _isValueANumberOrPercentsString(value) {
494
- return typeof value === 'number' || (typeof value === 'string' && value.endsWith('%'))
495
- }
496
-
497
- /**
498
- * main function to handle stretchingType
499
- * @param {Object} object
500
- */
501
- _adaptStretchingType(object) {
502
- if (object.width !== '100%' || object.height !== '100%' || !object.stretchingType)
503
- return;
504
-
505
- switch (object.stretchingType) {
506
- case 'inscribed':
507
- this._inscribe(object);
508
- break;
509
-
510
- case 'circumscribed':
511
- this._circumscribe(object);
512
- break;
513
-
514
- case 'false':
515
- break;
516
-
517
- default:
518
- Urso.logger.error('StretchingType value not valid!');
519
- break;
520
- }
521
- }
522
-
523
- /**
524
- * set property and adapt it (only for stretchingType)
525
- * @param {Object} object
526
- * @param {String} propertyName
527
- * @param {Number} value
528
- */
529
- _setPropertyAndAdaptIt(object, propertyName, value) {
530
- object[propertyName] = value;
531
- this.propertyChangeHandler(object, propertyName);
532
- }
533
-
534
- /**
535
- * set streching (only for stretchingType)
536
- * @param {Object} object
537
- * @param {Object} params
538
- */
539
- _setStreching(object, { scale, objectWidth, objectHeight }) {
540
- if (object.scaleX === 1)
541
- this._setPropertyAndAdaptIt(object, 'width', objectWidth * scale);
542
- else
543
- this._setPropertyAndAdaptIt(object, 'scaleX', scale);
544
-
545
- if (object.scaleY === 1)
546
- this._setPropertyAndAdaptIt(object, 'height', objectHeight * scale);
547
- else
548
- this._setPropertyAndAdaptIt(object, 'scaleY', scale);
549
- }
550
-
551
- /**
552
- * get object values for streching (only for stretchingType)
553
- * @param {Object} object
554
- */
555
- _getObjectValuesForStreching(object) {
556
- const objectWidth = this._getWidthAsNumber(object);
557
- const objectHeight = this._getHeightAsNumber(object);
558
- const parentWidth = this._getWidthAsNumber(object.parent);
559
- const parentHeight = this._getHeightAsNumber(object.parent);
560
-
561
- const scaleX = parentWidth / objectWidth;
562
- const scaleY = parentHeight / objectHeight;
563
-
564
- return { objectWidth, objectHeight, scaleX, scaleY };
565
- }
566
-
567
- /**
568
- * inscribe handler (only for stretchingType)
569
- * @param {Object} object
570
- */
571
- _inscribe(object) {
572
- const { objectWidth, objectHeight, scaleX, scaleY } = this._getObjectValuesForStreching(object);
573
- const scale = Math.min(scaleX, scaleY);
574
- this._setStreching(object, { scale, objectWidth, objectHeight });
575
- }
576
-
577
- /**
578
- * circumscribe handler (only for stretchingType)
579
- * @param {Object} object
580
- */
581
- _circumscribe(object) {
582
- const { objectWidth, objectHeight, scaleX, scaleY } = this._getObjectValuesForStreching(object);
583
- const scale = Math.max(scaleX, scaleY);
584
- this._setStreching(object, { scale, objectWidth, objectHeight });
585
- }
586
- }
587
-
1
+ /**
2
+ * adapter Urso to Pixi objects
3
+ */
4
+ class PropertyAdapter {
5
+
6
+ constructor() {
7
+ this.singleton = true;
8
+
9
+ /**
10
+ * dependencies, functions to handle changing property
11
+ */
12
+ this._dependencies = {
13
+ 'x': this._updateHorizontal.bind(this),
14
+ 'y': this._updateVertical.bind(this),
15
+ 'anchorX': this._updateHorizontal.bind(this),
16
+ 'anchorY': this._updateVertical.bind(this),
17
+ 'scaleX': this._adaptScaleX.bind(this),
18
+ 'scaleY': this._adaptScaleY.bind(this),
19
+ 'alignX': this._updateHorizontal.bind(this),
20
+ 'alignY': this._updateVertical.bind(this),
21
+ 'width': this._updateHorizontal.bind(this),
22
+ 'height': this._updateVertical.bind(this),
23
+ 'angle': this._updateAngle.bind(this),
24
+ 'stretchingType': this._adaptStretchingType.bind(this), //todo check on parent change
25
+ 'parent': this._parentChangeHandler.bind(this)
26
+ };
27
+
28
+ /**
29
+ * functions to handle changing parent property
30
+ */
31
+ this._parentToChildDependencies = {
32
+ 'width': { children: ['width'] },
33
+ 'height': { children: ['height'] },
34
+ 'anchorX': { children: ['x'] },
35
+ 'anchorY': { children: ['y'] },
36
+ 'stretchingType': { children: ['width', 'height'] }
37
+ };
38
+
39
+ /**
40
+ * parent types list
41
+ */
42
+ this._parentTypes = [
43
+ Urso.types.objects.COMPONENT,
44
+ Urso.types.objects.CONTAINER,
45
+ Urso.types.objects.DRAGCONTAINER,
46
+ Urso.types.objects.GROUP,
47
+ Urso.types.objects.SCROLLBOX,
48
+ Urso.types.objects.SLIDER,
49
+ Urso.types.objects.SPINE,
50
+ Urso.types.objects.WORLD
51
+ ];
52
+
53
+ /**
54
+ * types without ahchor list
55
+ */
56
+ this._typesWithoutAnchor = [
57
+ Urso.types.objects.CHECKBOX,
58
+ Urso.types.objects.EMITTER,
59
+ Urso.types.objects.EMITTERFX,
60
+ Urso.types.objects.GRAPHICS,
61
+ Urso.types.objects.HITAREA,
62
+ Urso.types.objects.MASK,
63
+ Urso.types.objects.NINESLICEPLANE,
64
+ Urso.types.objects.SLIDER,
65
+ Urso.types.objects.SPINE,
66
+ Urso.types.objects.TEXTINPUT,
67
+ Urso.types.objects.WORLD
68
+ ];
69
+ }
70
+
71
+ /**
72
+ * check is adaptive property
73
+ * @param {String} property
74
+ * @returns {Boolean}
75
+ */
76
+ isAdaptiveProperty(property) {
77
+ return Object.keys(this._dependencies).includes(property);
78
+ };
79
+
80
+ /**
81
+ * property change handler (main function)
82
+ * @param {Object} object
83
+ * @param {String} propertyName
84
+ */
85
+ propertyChangeHandler(object, propertyName) {
86
+ this._adaptProperty(object, propertyName);
87
+ this._adaptChildProperties(object, propertyName);
88
+ }
89
+
90
+ /**
91
+ * adapt property (launch handler changing property)
92
+ * @param {Object} object
93
+ * @param {String} propertyName
94
+ */
95
+ _adaptProperty(object, propertyName) {
96
+ if (this._dependencies[propertyName])
97
+ this._dependencies[propertyName](object);
98
+ }
99
+
100
+ /**
101
+ * main function to calculate x and width
102
+ * @param {Object} object
103
+ */
104
+ _updateHorizontal(object) {
105
+ let x = this._getXAsNumber(object);
106
+ x += this._adaptAnchorX(object);
107
+ x += this._adaptAlignX(object);
108
+ object._baseObject.x = x;
109
+
110
+ this._adaptWidth(object);
111
+ }
112
+
113
+ /**
114
+ * main function to calculate angle
115
+ * @param {Object} object
116
+ */
117
+ _updateAngle(object) {
118
+ object._baseObject.angle = object.angle;
119
+
120
+ if (!this._canBeParent(object)) {
121
+ return;
122
+ }
123
+
124
+ this._updateHorizontal(object);
125
+ this._updateVertical(object);
126
+ }
127
+
128
+ /**
129
+ * main function to calculate y and height
130
+ * @param {Object} object
131
+ */
132
+ _updateVertical(object) {
133
+ let y = this._getYAsNumber(object);
134
+ y += this._adaptAnchorY(object);
135
+ y += this._adaptAlignY(object);
136
+ object._baseObject.y = y;
137
+
138
+ this._adaptHeight(object);
139
+ }
140
+
141
+ /**
142
+ * set property value without adaptation
143
+ * @param {Object} object
144
+ * @param {String} propertyName
145
+ * @param {mixed} value
146
+ */
147
+ _setPropertyWithoutAdaption(object, propertyName, value) { //in error case
148
+ object[propertyName] = value;
149
+ }
150
+
151
+ /**
152
+ * adapt child properties if parent properties was changed
153
+ * @param {Object} object
154
+ * @param {String} propertyName
155
+ */
156
+ _adaptChildProperties(object, propertyName) {
157
+ const { children } = this._parentToChildDependencies[propertyName] || {};
158
+ const objectHasChildren = this._canBeParent(object) && object.hasOwnProperty('contents');
159
+
160
+ if (!children || !objectHasChildren)
161
+ return;
162
+
163
+ for (let dependency of children)
164
+ for (let child of object.contents)
165
+ this.propertyChangeHandler(child, dependency);
166
+ }
167
+
168
+ /**
169
+ * main handler when new parent was setted
170
+ * @param {Object} child
171
+ */
172
+ _parentChangeHandler(child) {
173
+ if (child.parent == null)
174
+ return;
175
+
176
+ for (let propertyName of this._propertiesDependentOnParent())
177
+ this.propertyChangeHandler(child, propertyName);
178
+ }
179
+
180
+ /**
181
+ * get array of properties dependent on parent
182
+ * //todo cache them and get just one time
183
+ * @returns {Array}
184
+ */
185
+ _propertiesDependentOnParent() {
186
+ const properties = [];
187
+
188
+ for (let propertyName of Object.keys(this._parentToChildDependencies)) {
189
+ const { children } = this._parentToChildDependencies[propertyName];
190
+
191
+ if (children)
192
+ for (let dependency of children)
193
+ properties.push(dependency);
194
+ }
195
+
196
+ return properties;
197
+ }
198
+
199
+ /**
200
+ * adapt anchorX
201
+ * @param {Object} object
202
+ */
203
+ _adaptAnchorX(object) {
204
+ if (typeof object.anchorX !== 'number' || object.anchorX < 0 || object.anchorX > 1)
205
+ Urso.logger.error('AnchorX value is not valid!', object);
206
+
207
+ if (this._canBeParent(object) && !this._typesWithoutAnchor.includes(object.type)) { //parent types
208
+ if (object.anchorX === 0)
209
+ return 0;
210
+
211
+ if (object.angle) {
212
+ return this._getAnchorOffsetByAngle(object, 'x');
213
+ }
214
+
215
+ const objectWidth = this._getWidthAsNumber(object);
216
+ return - objectWidth * object.anchorX;
217
+ } else if (!this._typesWithoutAnchor.includes(object.type)) { //regular type and not a type without anchor
218
+ const pixiObject = object._baseObject;
219
+ pixiObject.anchor.x = object.anchorX;
220
+ } else {
221
+ Urso.logger.warn(); ('AnchorX value cannot be used with this object type !', object);
222
+ }
223
+
224
+ return 0;
225
+ }
226
+
227
+ /**
228
+ * adapt anchorY
229
+ * @param {Object} object
230
+ */
231
+ _adaptAnchorY(object) {
232
+ if (typeof object.anchorY !== 'number' || object.anchorY < 0 || object.anchorY > 1)
233
+ Urso.logger.error('AnchorY value is not valid!', object);
234
+
235
+ if (this._canBeParent(object) && !this._typesWithoutAnchor.includes(object.type)) { //parent types
236
+ if (object.anchorY === 0)
237
+ return 0;
238
+
239
+ if (object.angle) {
240
+ return this._getAnchorOffsetByAngle(object, 'y');
241
+ }
242
+
243
+ const objectHeight = this._getHeightAsNumber(object);
244
+ return - objectHeight * object.anchorY;
245
+ } else if (!this._typesWithoutAnchor.includes(object.type)) { //regular type and not a type without anchor
246
+ const pixiObject = object._baseObject;
247
+ pixiObject.anchor.y = object.anchorY;
248
+ } else {
249
+ Urso.logger.warn(); ('AnchorY value cannot be used with this object type !', object);
250
+ }
251
+
252
+ return 0;
253
+ }
254
+
255
+ /**
256
+ * get anchor offset by angle for parent types
257
+ * @param {Object} object
258
+ * @param {String} side - x or y
259
+ * @returns {Number}
260
+ */
261
+ _getAnchorOffsetByAngle(object, side) { //side can be x or y
262
+ const objectWidth = this._getWidthAsNumber(object);
263
+ const objectHeight = this._getHeightAsNumber(object);
264
+ const xCatet = (objectWidth * object.anchorX);
265
+ const yCatet = (objectHeight * object.anchorY);
266
+ const offsetRadius = Math.sqrt(Math.pow(xCatet, 2) + Math.pow(yCatet, 2));
267
+ const angleRadian = Math.atan(xCatet / yCatet); //todo or yCatet/xCatet ?
268
+ const angle = Urso.helper.getAngle(angleRadian);
269
+ const offsetAngle = object.angle + angle;
270
+ const offsetFunction = side === 'x' ? 'cos' : 'sin';
271
+ const angleOffset = - offsetRadius * Math[offsetFunction](Urso.helper.getRadian(offsetAngle));
272
+
273
+ return angleOffset;
274
+ }
275
+
276
+ /**
277
+ * adapt scaleX
278
+ * @param {Object} object
279
+ */
280
+ _adaptScaleX(object) {
281
+ if (object.scaleX !== 1 && typeof object.width !== 'boolean') {
282
+ Urso.logger.error('ScaleX value cannot be set. Width already used!!');
283
+ this._setPropertyWithoutAdaption(object, 'scaleX', 1);
284
+ return;
285
+ }
286
+
287
+ if (typeof object.scaleX === 'number') {
288
+ const pixiObject = object._baseObject;
289
+ pixiObject.scale.x = object.scaleX;
290
+ } else
291
+ Urso.logger.error('ScaleX value is not valid!');
292
+ }
293
+
294
+ /**
295
+ * adapt scaleY
296
+ * @param {Object} object
297
+ */
298
+ _adaptScaleY(object) {
299
+ if (object.scaleY !== 1 && typeof object.height !== 'boolean') {
300
+ Urso.logger.error('ScaleY value cannot be set. Height already used!!');
301
+ this._setPropertyWithoutAdaption(object, 'scaleY', 1);
302
+ return;
303
+ }
304
+
305
+ if (typeof object.scaleY === 'number' && object.scaleY >= 0) { // TODO: CHECK SCALE CAN BE NEGATIVE
306
+ const pixiObject = object._baseObject;
307
+ pixiObject.scale.y = object.scaleY;
308
+ } else
309
+ Urso.logger.error('ScaleY value is not valid!');
310
+ }
311
+
312
+ /**
313
+ * adapt alignX
314
+ * @param {Object} object
315
+ */
316
+ _adaptAlignX(object) {
317
+ if (typeof object.alignX !== 'string') {
318
+ Urso.logger.error('AlignX value is not string!');
319
+ return 0;
320
+ }
321
+
322
+ switch (object.alignX) {
323
+ case 'left':
324
+ return 0;
325
+ case 'right':
326
+ return object.parent ? this._getWidthAsNumber(object.parent) : 0; //parentWidth
327
+ case 'center':
328
+ const parentWidth = object.parent ? this._getWidthAsNumber(object.parent) : 0;
329
+ return parentWidth / 2;
330
+ default:
331
+ Urso.logger.error('AlignX string is not valid!');
332
+ return 0;
333
+ }
334
+ }
335
+
336
+ /**
337
+ * adapt alignY
338
+ * @param {Object} object
339
+ */
340
+ _adaptAlignY(object) {
341
+ if (typeof object.alignY !== 'string') {
342
+ Urso.logger.error('AlignY value is not string!');
343
+ return 0;
344
+ }
345
+
346
+ switch (object.alignY) {
347
+ case 'top':
348
+ return 0;
349
+ case 'bottom':
350
+ return object.parent ? this._getHeightAsNumber(object.parent) : 0; //parentHeight
351
+ case 'center':
352
+ const parentHeight = object.parent ? this._getHeightAsNumber(object.parent) : 0;
353
+ return parentHeight / 2;
354
+ default:
355
+ Urso.logger.error('AlignY string is not valid!');
356
+ return 0;
357
+ }
358
+ }
359
+
360
+ /**
361
+ * adapt width
362
+ * @param {Object} object
363
+ */
364
+ _adaptWidth(object) {
365
+ if (typeof object.width !== 'boolean' && object.scaleX !== 1) {
366
+ Urso.logger.error('Width value cannot be set. ScaleX already used!!', object);
367
+ this._setPropertyWithoutAdaption(object, 'width', false);
368
+ return;
369
+ }
370
+
371
+ if (!object.width)
372
+ return;
373
+
374
+ if (!this._isValueANumberOrPercentsString(object.width))
375
+ return Urso.logger.error('Width value is not valid!!');
376
+
377
+ if (!this._canBeParent(object)) {
378
+ const pixiObject = object._baseObject;
379
+ pixiObject.width = this._getWidthAsNumber(object);
380
+ }
381
+ }
382
+
383
+ /**
384
+ * adapt height
385
+ * @param {Object} object
386
+ */
387
+ _adaptHeight(object) {
388
+ if (typeof object.height !== 'boolean' && object.scaleY !== 1) {
389
+ Urso.logger.error('Height value cannot be set. ScaleY already used!!', object);
390
+ this._setPropertyWithoutAdaption(object, 'height', false);
391
+ return;
392
+ }
393
+
394
+ if (!object.height)
395
+ return;
396
+
397
+ if (!this._isValueANumberOrPercentsString(object.height))
398
+ return Urso.logger.error('Height value not valid!');
399
+
400
+ if (!this._canBeParent(object)) {
401
+ const pixiObject = object._baseObject;
402
+ pixiObject.height = this._getHeightAsNumber(object);
403
+ }
404
+ }
405
+
406
+ /**
407
+ * get x number value
408
+ * @param {Object} object
409
+ * @returns {Number}
410
+ */
411
+ _getXAsNumber(object) {
412
+ return this._getPropertyAsNumber(object, 'x', 'width');
413
+ }
414
+
415
+ /**
416
+ * get y number value
417
+ * @param {Object} object
418
+ * @returns {Number}
419
+ */
420
+ _getYAsNumber(object) {
421
+ return this._getPropertyAsNumber(object, 'y', 'height');
422
+ }
423
+
424
+ /**
425
+ * get width number value
426
+ * @param {Object} object
427
+ * @returns {Number}
428
+ */
429
+ _getWidthAsNumber(object) {
430
+ return this._getPropertyAsNumber(object, 'width', 'width');
431
+ }
432
+
433
+ /**
434
+ * get height number value
435
+ * @param {Object} object
436
+ * @returns {Number}
437
+ */
438
+ _getHeightAsNumber(object) {
439
+ return this._getPropertyAsNumber(object, 'height', 'height');
440
+ }
441
+
442
+ /**
443
+ * get x, y, width or height number value
444
+ * @param {Object} object
445
+ * @param {String} propertyName
446
+ * @param {String} parentPropertyName
447
+ * @returns {Number}
448
+ */
449
+ _getPropertyAsNumber(object, propertyName, parentPropertyName) {
450
+ const propType = typeof object[propertyName];
451
+
452
+ switch (propType) {
453
+ case 'number':
454
+ return object[propertyName];
455
+
456
+ case 'string':
457
+ const parentValue = this._getPropertyAsNumber(object.parent, parentPropertyName, parentPropertyName);
458
+ return this._getRoundedPercentageOfNumber(object[propertyName], parentValue);
459
+
460
+ case 'boolean':
461
+ return this._getPropertyAsNumber(object.parent, propertyName, parentPropertyName)
462
+
463
+ default:
464
+ Urso.logger.error('Property value not number or string!', object, propertyName);
465
+ return;
466
+ }
467
+ }
468
+
469
+ /**
470
+ * get rounded persents of number
471
+ * @param {String} percentsString
472
+ * @param {Number} number
473
+ * @returns {Number}
474
+ */
475
+ _getRoundedPercentageOfNumber(percentsString, number) {
476
+ const percentsFloat = parseFloat(percentsString);
477
+ return ~~(percentsFloat * number / 100);
478
+ }
479
+
480
+ /**
481
+ * check can be object a parent (by type)
482
+ * @param {Object} object
483
+ * @returns {Boolean}
484
+ */
485
+ _canBeParent(object) {
486
+ return this._parentTypes.includes(object.type);
487
+ }
488
+
489
+ /**
490
+ * check is value a number or a percents string
491
+ * @param {mixed} value
492
+ * @returns {Boolean}
493
+ */
494
+ _isValueANumberOrPercentsString(value) {
495
+ return typeof value === 'number' || (typeof value === 'string' && value.endsWith('%'))
496
+ }
497
+
498
+ /**
499
+ * main function to handle stretchingType
500
+ * @param {Object} object
501
+ */
502
+ _adaptStretchingType(object) {
503
+ if (object.width !== '100%' || object.height !== '100%' || !object.stretchingType)
504
+ return;
505
+
506
+ switch (object.stretchingType) {
507
+ case 'inscribed':
508
+ this._inscribe(object);
509
+ break;
510
+
511
+ case 'circumscribed':
512
+ this._circumscribe(object);
513
+ break;
514
+
515
+ case 'false':
516
+ break;
517
+
518
+ default:
519
+ Urso.logger.error('StretchingType value not valid!');
520
+ break;
521
+ }
522
+ }
523
+
524
+ /**
525
+ * set property and adapt it (only for stretchingType)
526
+ * @param {Object} object
527
+ * @param {String} propertyName
528
+ * @param {Number} value
529
+ */
530
+ _setPropertyAndAdaptIt(object, propertyName, value) {
531
+ object[propertyName] = value;
532
+ this.propertyChangeHandler(object, propertyName);
533
+ }
534
+
535
+ /**
536
+ * set streching (only for stretchingType)
537
+ * @param {Object} object
538
+ * @param {Object} params
539
+ */
540
+ _setStreching(object, { scale, objectWidth, objectHeight }) {
541
+ if (object.scaleX === 1)
542
+ this._setPropertyAndAdaptIt(object, 'width', objectWidth * scale);
543
+ else
544
+ this._setPropertyAndAdaptIt(object, 'scaleX', scale);
545
+
546
+ if (object.scaleY === 1)
547
+ this._setPropertyAndAdaptIt(object, 'height', objectHeight * scale);
548
+ else
549
+ this._setPropertyAndAdaptIt(object, 'scaleY', scale);
550
+ }
551
+
552
+ /**
553
+ * get object values for streching (only for stretchingType)
554
+ * @param {Object} object
555
+ */
556
+ _getObjectValuesForStreching(object) {
557
+ const objectWidth = this._getWidthAsNumber(object);
558
+ const objectHeight = this._getHeightAsNumber(object);
559
+ const parentWidth = this._getWidthAsNumber(object.parent);
560
+ const parentHeight = this._getHeightAsNumber(object.parent);
561
+
562
+ const scaleX = parentWidth / objectWidth;
563
+ const scaleY = parentHeight / objectHeight;
564
+
565
+ return { objectWidth, objectHeight, scaleX, scaleY };
566
+ }
567
+
568
+ /**
569
+ * inscribe handler (only for stretchingType)
570
+ * @param {Object} object
571
+ */
572
+ _inscribe(object) {
573
+ const { objectWidth, objectHeight, scaleX, scaleY } = this._getObjectValuesForStreching(object);
574
+ const scale = Math.min(scaleX, scaleY);
575
+ this._setStreching(object, { scale, objectWidth, objectHeight });
576
+ }
577
+
578
+ /**
579
+ * circumscribe handler (only for stretchingType)
580
+ * @param {Object} object
581
+ */
582
+ _circumscribe(object) {
583
+ const { objectWidth, objectHeight, scaleX, scaleY } = this._getObjectValuesForStreching(object);
584
+ const scale = Math.max(scaleX, scaleY);
585
+ this._setStreching(object, { scale, objectWidth, objectHeight });
586
+ }
587
+ }
588
+
588
589
  module.exports = PropertyAdapter;