@urso/core 0.3.10 → 0.4.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.
Files changed (144) hide show
  1. package/.babelrc +11 -11
  2. package/README.md +10 -10
  3. package/build/js/index.js +1 -1
  4. package/build/js/index.js.LICENSE.txt +29 -29
  5. package/package.json +51 -51
  6. package/src/js/app.js +77 -77
  7. package/src/js/components/_info.js +8 -8
  8. package/src/js/components/base/_info.js +3 -3
  9. package/src/js/components/base/controller.js +78 -78
  10. package/src/js/components/debug/_info.js +7 -7
  11. package/src/js/components/debug/controller.js +38 -38
  12. package/src/js/components/debug/coords.js +23 -23
  13. package/src/js/components/debug/fps.js +34 -34
  14. package/src/js/components/debug/template.js +55 -55
  15. package/src/js/components/debug/timescale.js +60 -60
  16. package/src/js/components/deviceRotate/_info.js +3 -3
  17. package/src/js/components/deviceRotate/controller.js +86 -86
  18. package/src/js/components/fullscreen/_info.js +6 -6
  19. package/src/js/components/fullscreen/android.js +104 -104
  20. package/src/js/components/fullscreen/controller.js +64 -64
  21. package/src/js/components/fullscreen/desktop.js +49 -49
  22. package/src/js/components/fullscreen/ios.js +111 -111
  23. package/src/js/components/loader/_info.js +4 -4
  24. package/src/js/components/loader/controller.js +66 -66
  25. package/src/js/components/loader/template.js +70 -70
  26. package/src/js/components/soundInitialPopup/_info.js +3 -3
  27. package/src/js/components/soundInitialPopup/controller.js +42 -42
  28. package/src/js/components/soundInitialPopup/template.js +109 -109
  29. package/src/js/components/stateDriven/_info.js +3 -3
  30. package/src/js/components/stateDriven/controller.js +118 -118
  31. package/src/js/config/load.js +5 -5
  32. package/src/js/config/main.js +10 -10
  33. package/src/js/extra/_info.js +22 -22
  34. package/src/js/extra/browserEvents.js +38 -38
  35. package/src/js/extra/setTimeout.js +7 -7
  36. package/src/js/index.js +8 -8
  37. package/src/js/lib/_info.js +13 -13
  38. package/src/js/lib/cache.js +105 -105
  39. package/src/js/lib/composition.js +85 -89
  40. package/src/js/lib/device.js +1286 -1276
  41. package/src/js/lib/helper.js +539 -539
  42. package/src/js/lib/loader.js +127 -127
  43. package/src/js/lib/localData.js +15 -15
  44. package/src/js/lib/logger.js +22 -22
  45. package/src/js/lib/math.js +35 -35
  46. package/src/js/lib/objectPool.js +54 -54
  47. package/src/js/lib/time.js +18 -18
  48. package/src/js/lib/tween.js +147 -147
  49. package/src/js/modules/_info.js +11 -11
  50. package/src/js/modules/assets/_info.js +7 -7
  51. package/src/js/modules/assets/baseModel.js +18 -18
  52. package/src/js/modules/assets/config.js +37 -35
  53. package/src/js/modules/assets/controller.js +46 -39
  54. package/src/js/modules/assets/models/_info.js +11 -11
  55. package/src/js/modules/assets/models/atlas.js +8 -8
  56. package/src/js/modules/assets/models/audiosprite.js +27 -27
  57. package/src/js/modules/assets/models/bitmapFont.js +8 -8
  58. package/src/js/modules/assets/models/container.js +16 -16
  59. package/src/js/modules/assets/models/font.js +8 -8
  60. package/src/js/modules/assets/models/image.js +13 -13
  61. package/src/js/modules/assets/models/json.js +8 -8
  62. package/src/js/modules/assets/models/sound.js +14 -14
  63. package/src/js/modules/assets/models/spine.js +14 -14
  64. package/src/js/modules/assets/service.js +356 -353
  65. package/src/js/modules/instances/_info.js +3 -3
  66. package/src/js/modules/instances/controller.js +251 -219
  67. package/src/js/modules/logic/_info.js +4 -4
  68. package/src/js/modules/logic/config/_info.js +2 -2
  69. package/src/js/modules/logic/config/sounds.js +23 -23
  70. package/src/js/modules/logic/controller.js +48 -48
  71. package/src/js/modules/logic/sounds.js +96 -96
  72. package/src/js/modules/objects/_info.js +11 -11
  73. package/src/js/modules/objects/baseModel.js +175 -161
  74. package/src/js/modules/objects/cache.js +99 -99
  75. package/src/js/modules/objects/controller.js +131 -121
  76. package/src/js/modules/objects/create.js +234 -230
  77. package/src/js/modules/objects/find.js +140 -140
  78. package/src/js/modules/objects/models/_info.js +24 -24
  79. package/src/js/modules/objects/models/atlasImage.js +50 -50
  80. package/src/js/modules/objects/models/bitmapText.js +23 -23
  81. package/src/js/modules/objects/models/button.js +184 -184
  82. package/src/js/modules/objects/models/buttonComposite.js +35 -35
  83. package/src/js/modules/objects/models/checkbox.js +96 -96
  84. package/src/js/modules/objects/models/collection.js +54 -54
  85. package/src/js/modules/objects/models/component.js +44 -44
  86. package/src/js/modules/objects/models/container.js +19 -19
  87. package/src/js/modules/objects/models/emitter.js +54 -54
  88. package/src/js/modules/objects/models/graphics.js +38 -38
  89. package/src/js/modules/objects/models/group.js +19 -19
  90. package/src/js/modules/objects/models/hitArea.js +104 -104
  91. package/src/js/modules/objects/models/image.js +34 -34
  92. package/src/js/modules/objects/models/imagesAnimation.js +113 -113
  93. package/src/js/modules/objects/models/mask.js +38 -38
  94. package/src/js/modules/objects/models/scrollbox.js +61 -61
  95. package/src/js/modules/objects/models/slider.js +223 -223
  96. package/src/js/modules/objects/models/spine.js +138 -89
  97. package/src/js/modules/objects/models/text.js +38 -38
  98. package/src/js/modules/objects/models/textInput.js +66 -66
  99. package/src/js/modules/objects/models/toggle.js +178 -178
  100. package/src/js/modules/objects/models/world.js +19 -19
  101. package/src/js/modules/objects/propertyAdapter.js +421 -421
  102. package/src/js/modules/objects/proxy.js +182 -182
  103. package/src/js/modules/objects/styles.js +116 -116
  104. package/src/js/modules/observer/_info.js +4 -4
  105. package/src/js/modules/observer/controller.js +99 -99
  106. package/src/js/modules/observer/events.js +38 -38
  107. package/src/js/modules/scenes/_info.js +8 -8
  108. package/src/js/modules/scenes/controller.js +46 -42
  109. package/src/js/modules/scenes/model.js +35 -35
  110. package/src/js/modules/scenes/pixiWrapper.js +202 -202
  111. package/src/js/modules/scenes/resolutions.js +172 -176
  112. package/src/js/modules/scenes/resolutionsConfig.js +73 -73
  113. package/src/js/modules/scenes/service.js +105 -92
  114. package/src/js/modules/soundManager/_info.js +3 -3
  115. package/src/js/modules/soundManager/controller.js +99 -99
  116. package/src/js/modules/soundManager/soundSprite.js +202 -202
  117. package/src/js/modules/statesManager/_info.js +12 -12
  118. package/src/js/modules/statesManager/action.js +60 -60
  119. package/src/js/modules/statesManager/actions/_info.js +3 -3
  120. package/src/js/modules/statesManager/all.js +23 -23
  121. package/src/js/modules/statesManager/configStates.js +71 -71
  122. package/src/js/modules/statesManager/controller.js +170 -170
  123. package/src/js/modules/statesManager/functionsStorage.js +82 -82
  124. package/src/js/modules/statesManager/helper.js +27 -27
  125. package/src/js/modules/statesManager/race.js +75 -75
  126. package/src/js/modules/statesManager/sequence.js +47 -47
  127. package/src/js/modules/template/_info.js +6 -6
  128. package/src/js/modules/template/controller.js +28 -28
  129. package/src/js/modules/template/model.js +11 -11
  130. package/src/js/modules/template/service.js +137 -125
  131. package/src/js/modules/template/types.js +44 -44
  132. package/src/js/modules/transport/_info.js +8 -8
  133. package/src/js/modules/transport/baseConnectionType.js +24 -24
  134. package/src/js/modules/transport/config.js +13 -13
  135. package/src/js/modules/transport/connectionTypes/_info.js +3 -3
  136. package/src/js/modules/transport/connectionTypes/websocket.js +74 -74
  137. package/src/js/modules/transport/connectionTypes/xhr.js +44 -44
  138. package/src/js/modules/transport/controller.js +48 -48
  139. package/src/js/modules/transport/decorator.js +17 -17
  140. package/src/js/modules/transport/service.js +153 -153
  141. package/src/js/templates/_info.js +4 -4
  142. package/src/js/templates/groups/_info.js +1 -1
  143. package/src/js/templates/scenes/_info.js +1 -1
  144. package/webpack.config.js +47 -47
@@ -1,176 +1,172 @@
1
- class ModulesScenesResolutions {
2
-
3
- constructor() {
4
- this.singleton = true;
5
- this._activeResolution = false; //object
6
- this._templateSize = { orientation: 0, width: 0, height: 0 };
7
- this._orientations = { landscape: 'landscape', portrait: 'portrait' }
8
- this._currentOrientation = null;
9
-
10
- this.refreshSceneSize = this.refreshSceneSize.bind(this);
11
- this.preResize = this.preResize.bind(this);
12
- this.refreshSceneSize();
13
-
14
- //TODO optimization (performance)
15
- /*if (devicePixelRatio > 2)
16
- devicePixelRatio = 2;*/ // when we are calculating canvas size
17
- }
18
-
19
- _subscribeOnce() {
20
- this.addListener(Urso.events.EXTRA_BROWSEREVENTS_WINDOW_PRE_RESIZE, this.preResize, true);
21
- this.addListener(Urso.events.EXTRA_BROWSEREVENTS_WINDOW_RESIZE, this.refreshSceneSize, true);
22
- this.addListener(Urso.events.MODULES_SCENES_NEW_SCENE_INIT, this.refreshSceneSize, true);
23
- }
24
-
25
- getTemplateSize() {
26
- return this._templateSize;
27
- }
28
-
29
- preResize() {
30
- if (Urso.helper.mobileAndTabletCheck())
31
- this.getInstance('PixiWrapper').hideCanvas();
32
- }
33
-
34
- refreshSceneSize() {
35
- let windowSize = this._getWindowSize();
36
- let orientation = this._getOrientation(windowSize);
37
- let configResolution = this._getResolutionConfig(windowSize);
38
-
39
- let windowRatio = windowSize.width / windowSize.height;
40
- let optimalRatio = this._getOptimalRatio(configResolution, windowRatio, orientation);
41
-
42
- let currentResolution = Urso.helper.objectClone(configResolution);
43
- currentResolution.name = 'currentResolution';
44
- currentResolution.base = configResolution;
45
- currentResolution.width = (optimalRatio > windowRatio) ? Math.floor(windowSize.width) : Math.floor(Math.floor(windowSize.height) * optimalRatio);
46
- currentResolution.height = (optimalRatio > windowRatio) ? Math.floor(Math.floor(windowSize.width) / optimalRatio) : Math.floor(windowSize.height);
47
-
48
- this._templateSize = this._calculateTemplateSize(currentResolution);
49
- this._applyResolutionToPixi(currentResolution);
50
-
51
- console.log('[SCENE] New Orientation', orientation);
52
- console.log('[SCENE] New Resolution', currentResolution, 'windowSize:', windowSize);
53
- console.log('[SCENE] New Template Size', this._templateSize);
54
-
55
- //update InstancesModes
56
- Object.values(this._orientations).forEach((orientationValue) => Urso.removeInstancesMode(orientationValue + 'Orientation'));
57
- Urso.addInstancesMode(orientation + 'Orientation');
58
-
59
- //send new resolution event
60
- this.emit(Urso.events.MODULES_SCENES_NEW_RESOLUTION, { resolution: currentResolution, template: this._templateSize });
61
-
62
- if (this._currentOrientation !== this._templateSize.orientation) {
63
- this._currentOrientation = this._templateSize.orientation;
64
- this.emit(Urso.events.MODULES_SCENES_ORIENTATION_CHANGE, this._templateSize.orientation);
65
- }
66
-
67
- return true;
68
- };
69
-
70
- _getWindowSize() {
71
- const iOS = Urso.device.iOS;
72
- const { width, height } = document.body.getBoundingClientRect();
73
-
74
- let windowSize = {
75
- width: iOS ? window.innerWidth : width,
76
- height: iOS ? window.innerHeight : height
77
- };
78
-
79
- if (window.devicePixelRatio && window.devicePixelRatio !== 1) {
80
- windowSize.width *= window.devicePixelRatio;
81
- windowSize.height *= window.devicePixelRatio;
82
- }
83
-
84
- return windowSize;
85
- }
86
-
87
- _getOrientation(windowSize) {
88
- return windowSize.width > windowSize.height ? this._orientations.landscape : this._orientations.portrait; //todo move to constants
89
- }
90
-
91
- _getResolutionConfig(windowSize) {
92
- let orientation = this._getOrientation(windowSize);
93
- let mainDimension = windowSize.width > windowSize.height ? 'width' : 'height'; //todo move to constants
94
- let config = this.getInstance('ResolutionsConfig').get();
95
- let currentResolution = config[0];
96
-
97
- //select optimal resolution from config
98
- for (let resolution of config) {
99
- if (resolution.orientation !== orientation)
100
- continue;
101
-
102
- if (
103
- (currentResolution.orientation !== orientation) ||
104
- (
105
- currentResolution[mainDimension] < resolution[mainDimension] &&
106
- resolution[mainDimension] < windowSize[mainDimension]
107
- ) ||
108
- (
109
- windowSize[mainDimension] < currentResolution[mainDimension] &&
110
- resolution[mainDimension] < currentResolution[mainDimension]
111
- )
112
- )
113
- currentResolution = resolution;
114
- }
115
-
116
- return currentResolution;
117
- }
118
-
119
- _getOptimalRatio(configResolution, windowRatio, orientation) {
120
- let optimalRatio = configResolution.width / configResolution.height;
121
-
122
- if (configResolution.adaptive) {
123
- let display = !Urso.helper.mobileAndTabletCheck() ? 'desktop' : 'mobile'; //todo move to constants
124
- let adaptiveParams = this.getInstance('ResolutionsConfig').getAdaptive()[display];
125
-
126
- if (adaptiveParams.supported) {
127
- let limits = adaptiveParams.limits[orientation];
128
- optimalRatio = Urso.math.intMakeBetween(windowRatio, limits.min, limits.max);
129
- }
130
- }
131
-
132
- return optimalRatio;
133
- }
134
-
135
- _calculateTemplateSize(resolution) {
136
- this._templateSize.orientation = resolution.orientation;
137
- this._templateSize.width = resolution.base.width;
138
- this._templateSize.height = resolution.base.height;
139
-
140
- let dimensionsArray = ['width', 'height'];
141
-
142
- //adaptive corrections
143
- if (resolution.adaptive) {
144
- let dimensionsPassiveKey = (resolution.width / resolution.height > resolution.base.width / resolution.base.height) ? 0 : 1;
145
- let dimensionsMainKey = (dimensionsPassiveKey === 1) ? 0 : 1;
146
-
147
- this._templateSize[dimensionsArray[dimensionsPassiveKey]] =
148
- ~~(
149
- resolution[dimensionsArray[dimensionsPassiveKey]] *
150
- resolution.base[dimensionsArray[dimensionsMainKey]] / resolution[dimensionsArray[dimensionsMainKey]]
151
- );
152
- }
153
-
154
- return this._templateSize;
155
- }
156
-
157
- _applyResolutionToPixi(resolution) {
158
- let maxResolutionFactor = Math.min(this.getInstance('ResolutionsConfig').maxSize() / Math.max(resolution.width, resolution.height), 1);
159
- let dp = window.devicePixelRatio;
160
- let canvasSize = {
161
- width: ~~(resolution.width * maxResolutionFactor),
162
- height: ~~(resolution.height * maxResolutionFactor)
163
- };
164
-
165
- this.getInstance('PixiWrapper').showCanvas();
166
- this.getInstance('PixiWrapper').resize(canvasSize.width, canvasSize.height);
167
- this.getInstance('PixiWrapper').setWorldScale(canvasSize.width / this._templateSize.width, canvasSize.height / this._templateSize.height);
168
- this.getInstance('PixiWrapper').setCanvasWidth(resolution.width / dp);
169
- this.getInstance('PixiWrapper').setCanvasHeight(resolution.height / dp);
170
-
171
- this._activeResolution = resolution;
172
- return true;
173
- };
174
- }
175
-
176
- module.exports = ModulesScenesResolutions;
1
+ class ModulesScenesResolutions {
2
+
3
+ constructor() {
4
+ this.singleton = true;
5
+ this._activeResolution = false; //object
6
+ this._templateSize = { orientation: 0, width: 0, height: 0 };
7
+ this._currentOrientation = null;
8
+
9
+ this.refreshSceneSize = this.refreshSceneSize.bind(this);
10
+ this.preResize = this.preResize.bind(this);
11
+ this.refreshSceneSize();
12
+
13
+ //TODO optimization (performance)
14
+ /*if (devicePixelRatio > 2)
15
+ devicePixelRatio = 2;*/ // when we are calculating canvas size
16
+ }
17
+
18
+ _subscribeOnce() {
19
+ this.addListener(Urso.events.EXTRA_BROWSEREVENTS_WINDOW_PRE_RESIZE, this.preResize, true);
20
+ this.addListener(Urso.events.EXTRA_BROWSEREVENTS_WINDOW_RESIZE, this.refreshSceneSize, true);
21
+ this.addListener(Urso.events.MODULES_SCENES_NEW_SCENE_INIT, this.refreshSceneSize, true);
22
+ }
23
+
24
+ getTemplateSize() {
25
+ return this._templateSize;
26
+ }
27
+
28
+ preResize() {
29
+ if (Urso.helper.mobileAndTabletCheck())
30
+ this.getInstance('PixiWrapper').hideCanvas();
31
+ }
32
+
33
+ refreshSceneSize() {
34
+ let windowSize = this._getWindowSize();
35
+ let orientation = this._getOrientation(windowSize);
36
+ let configResolution = this._getResolutionConfig(windowSize);
37
+
38
+ let windowRatio = windowSize.width / windowSize.height;
39
+ let optimalRatio = this._getOptimalRatio(configResolution, windowRatio, orientation);
40
+
41
+ let currentResolution = Urso.helper.objectClone(configResolution);
42
+ currentResolution.name = 'currentResolution';
43
+ currentResolution.base = configResolution;
44
+ currentResolution.width = (optimalRatio > windowRatio) ? Math.floor(windowSize.width) : Math.floor(Math.floor(windowSize.height) * optimalRatio);
45
+ currentResolution.height = (optimalRatio > windowRatio) ? Math.floor(Math.floor(windowSize.width) / optimalRatio) : Math.floor(windowSize.height);
46
+
47
+ this._templateSize = this._calculateTemplateSize(currentResolution);
48
+ this._applyResolutionToPixi(currentResolution);
49
+
50
+ console.log('[SCENE] New Orientation', orientation);
51
+ console.log('[SCENE] New Resolution', currentResolution, 'windowSize:', windowSize);
52
+ console.log('[SCENE] New Template Size', this._templateSize);
53
+
54
+ //update InstancesModes
55
+ Object.values(Urso.device.ScreenOrientation).forEach((orientationValue) => Urso.removeInstancesMode(orientationValue + 'Orientation'));
56
+ Urso.addInstancesMode(orientation + 'Orientation');
57
+
58
+ //send new resolution event
59
+ this.emit(Urso.events.MODULES_SCENES_NEW_RESOLUTION, { resolution: currentResolution, template: this._templateSize });
60
+
61
+ if (this._currentOrientation !== this._templateSize.orientation) {
62
+ this._currentOrientation = this._templateSize.orientation;
63
+ this.emit(Urso.events.MODULES_SCENES_ORIENTATION_CHANGE, this._templateSize.orientation);
64
+ }
65
+
66
+ return true;
67
+ };
68
+
69
+ _getWindowSize() {
70
+ let windowSize = {
71
+ width: window.innerWidth,
72
+ height: window.innerHeight
73
+ };
74
+
75
+ if (window.devicePixelRatio && window.devicePixelRatio !== 1) {
76
+ windowSize.width *= window.devicePixelRatio;
77
+ windowSize.height *= window.devicePixelRatio;
78
+ }
79
+
80
+ return windowSize;
81
+ }
82
+
83
+ _getOrientation(windowSize) {
84
+ return windowSize.width > windowSize.height ? Urso.device.ScreenOrientation.LANDSCAPE : Urso.device.ScreenOrientation.PORTRAIT;
85
+ }
86
+
87
+ _getResolutionConfig(windowSize) {
88
+ let orientation = this._getOrientation(windowSize);
89
+ let mainDimension = windowSize.width > windowSize.height ? 'width' : 'height'; //todo move to constants
90
+ let config = this.getInstance('ResolutionsConfig').get();
91
+ let currentResolution = config[0];
92
+
93
+ //select optimal resolution from config
94
+ for (let resolution of config) {
95
+ if (resolution.orientation !== orientation)
96
+ continue;
97
+
98
+ if (
99
+ (currentResolution.orientation !== orientation) ||
100
+ (
101
+ currentResolution[mainDimension] < resolution[mainDimension] &&
102
+ resolution[mainDimension] < windowSize[mainDimension]
103
+ ) ||
104
+ (
105
+ windowSize[mainDimension] < currentResolution[mainDimension] &&
106
+ resolution[mainDimension] < currentResolution[mainDimension]
107
+ )
108
+ )
109
+ currentResolution = resolution;
110
+ }
111
+
112
+ return currentResolution;
113
+ }
114
+
115
+ _getOptimalRatio(configResolution, windowRatio, orientation) {
116
+ let optimalRatio = configResolution.width / configResolution.height;
117
+
118
+ if (configResolution.adaptive) {
119
+ let display = !Urso.helper.mobileAndTabletCheck() ? 'desktop' : 'mobile'; //todo move to constants
120
+ let adaptiveParams = this.getInstance('ResolutionsConfig').getAdaptive()[display];
121
+
122
+ if (adaptiveParams.supported) {
123
+ let limits = adaptiveParams.limits[orientation];
124
+ optimalRatio = Urso.math.intMakeBetween(windowRatio, limits.min, limits.max);
125
+ }
126
+ }
127
+
128
+ return optimalRatio;
129
+ }
130
+
131
+ _calculateTemplateSize(resolution) {
132
+ this._templateSize.orientation = resolution.orientation;
133
+ this._templateSize.width = resolution.base.width;
134
+ this._templateSize.height = resolution.base.height;
135
+
136
+ let dimensionsArray = ['width', 'height'];
137
+
138
+ //adaptive corrections
139
+ if (resolution.adaptive) {
140
+ let dimensionsPassiveKey = (resolution.width / resolution.height > resolution.base.width / resolution.base.height) ? 0 : 1;
141
+ let dimensionsMainKey = (dimensionsPassiveKey === 1) ? 0 : 1;
142
+
143
+ this._templateSize[dimensionsArray[dimensionsPassiveKey]] =
144
+ ~~(
145
+ resolution[dimensionsArray[dimensionsPassiveKey]] *
146
+ resolution.base[dimensionsArray[dimensionsMainKey]] / resolution[dimensionsArray[dimensionsMainKey]]
147
+ );
148
+ }
149
+
150
+ return this._templateSize;
151
+ }
152
+
153
+ _applyResolutionToPixi(resolution) {
154
+ let maxResolutionFactor = Math.min(this.getInstance('ResolutionsConfig').maxSize() / Math.max(resolution.width, resolution.height), 1);
155
+ let dp = window.devicePixelRatio;
156
+ let canvasSize = {
157
+ width: ~~(resolution.width * maxResolutionFactor),
158
+ height: ~~(resolution.height * maxResolutionFactor)
159
+ };
160
+
161
+ this.getInstance('PixiWrapper').showCanvas();
162
+ this.getInstance('PixiWrapper').resize(canvasSize.width, canvasSize.height);
163
+ this.getInstance('PixiWrapper').setWorldScale(canvasSize.width / this._templateSize.width, canvasSize.height / this._templateSize.height);
164
+ this.getInstance('PixiWrapper').setCanvasWidth(resolution.width / dp);
165
+ this.getInstance('PixiWrapper').setCanvasHeight(resolution.height / dp);
166
+
167
+ this._activeResolution = resolution;
168
+ return true;
169
+ };
170
+ }
171
+
172
+ module.exports = ModulesScenesResolutions;
@@ -1,73 +1,73 @@
1
- class ModulesScenesResolutionsConfig {
2
- constructor() {
3
- this.singleton = true;
4
-
5
- this._orientations = ['landscape', 'portrait'];
6
-
7
- this.contents = [
8
- {
9
- "name": 'default',
10
- "width": 1920,
11
- "height": 1080,
12
- "orientation": 'landscape',
13
- "adaptive": true
14
- }
15
- ];
16
-
17
- this.adaptiveConfig = {//works only if "adaptive": true for current resolution
18
- desktop: {
19
- supported: true,
20
- limits: {
21
- landscape: {
22
- min: 1, // width:height factor
23
- max: 2
24
- },
25
- portrait: {
26
- min: 0.5,
27
- max: 1
28
- }
29
- }
30
- },
31
- mobile: {
32
- supported: true,
33
- limits: {
34
- landscape: {
35
- min: 1, // width:height factor
36
- max: 2
37
- },
38
- portrait: {
39
- min: 0.5,
40
- max: 1
41
- }
42
- }
43
- }
44
- };
45
- }
46
-
47
- get() {
48
- return this.contents;
49
- };
50
-
51
-
52
- getAdaptive() {
53
- return this.adaptiveConfig;
54
- };
55
-
56
- maxSize() {
57
- return Math.max(this.maxWidth(), this.maxHeight());
58
- };
59
-
60
- maxWidth() {
61
- return this._maxDimension.call(this, 'width');
62
- };
63
-
64
- maxHeight() {
65
- return this._maxDimension.call(this, 'height');
66
- };
67
-
68
- _maxDimension(dim) {
69
- return this.contents.reduce((result, resolution) => resolution[dim] > result ? resolution[dim] : result, 0);
70
- };
71
- }
72
-
73
- module.exports = ModulesScenesResolutionsConfig;
1
+ class ModulesScenesResolutionsConfig {
2
+ constructor() {
3
+ this.singleton = true;
4
+
5
+ this._orientations = [Urso.device.ScreenOrientation.LANDSCAPE, Urso.device.ScreenOrientation.PORTRAIT]; //you can use only one orientation for config contents
6
+
7
+ this.contents = [
8
+ {
9
+ "name": 'default',
10
+ "width": 1920,
11
+ "height": 1080,
12
+ "orientation": Urso.device.ScreenOrientation.LANDSCAPE,
13
+ "adaptive": true
14
+ }
15
+ ];
16
+
17
+ this.adaptiveConfig = {//works only if "adaptive": true for current resolution
18
+ desktop: {
19
+ supported: true,
20
+ limits: {
21
+ landscape: {
22
+ min: 1, // width:height factor
23
+ max: 2
24
+ },
25
+ portrait: {
26
+ min: 0.5,
27
+ max: 1
28
+ }
29
+ }
30
+ },
31
+ mobile: {
32
+ supported: true,
33
+ limits: {
34
+ landscape: {
35
+ min: 1, // width:height factor
36
+ max: 2
37
+ },
38
+ portrait: {
39
+ min: 0.5,
40
+ max: 1
41
+ }
42
+ }
43
+ }
44
+ };
45
+ }
46
+
47
+ get() {
48
+ return this.contents;
49
+ };
50
+
51
+
52
+ getAdaptive() {
53
+ return this.adaptiveConfig;
54
+ };
55
+
56
+ maxSize() {
57
+ return Math.max(this.maxWidth(), this.maxHeight());
58
+ };
59
+
60
+ maxWidth() {
61
+ return this._maxDimension.call(this, 'width');
62
+ };
63
+
64
+ maxHeight() {
65
+ return this._maxDimension.call(this, 'height');
66
+ };
67
+
68
+ _maxDimension(dim) {
69
+ return this.contents.reduce((result, resolution) => resolution[dim] > result ? resolution[dim] : result, 0);
70
+ };
71
+ }
72
+
73
+ module.exports = ModulesScenesResolutionsConfig;