@urso/core 0.4.7 → 0.4.11
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/build/js/index.js +1 -1
- package/package.json +1 -1
- package/src/js/components/fullscreen/controller.js +10 -1
- package/src/js/components/fullscreen/ios.js +7 -3
- package/src/js/extra/_info.js +2 -0
- package/src/js/extra/pixiPatch.js +77 -0
- package/src/js/modules/assets/service.js +10 -1
- package/src/js/modules/objects/models/text.js +5 -0
- package/src/js/modules/objects/proxy.js +1 -0
- package/src/js/modules/observer/events.js +3 -0
- package/src/js/modules/scenes/service.js +2 -0
package/package.json
CHANGED
|
@@ -7,8 +7,10 @@ class ComponentsFullscreenController extends ComponentsBaseController {
|
|
|
7
7
|
|
|
8
8
|
this._fullscreenActivator = null;
|
|
9
9
|
this._resolutionsConfig = null;
|
|
10
|
+
this.lastResizeFullscreenResult;
|
|
10
11
|
|
|
11
12
|
this.createActivator();
|
|
13
|
+
this._resizeHandler();
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
createActivator() {
|
|
@@ -53,7 +55,14 @@ class ComponentsFullscreenController extends ComponentsBaseController {
|
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
_resizeHandler() {
|
|
56
|
-
|
|
58
|
+
const isFullscreen = this.isFullscreen;
|
|
59
|
+
|
|
60
|
+
if (this.lastResizeFullscreenResult === isFullscreen)
|
|
61
|
+
return;
|
|
62
|
+
|
|
63
|
+
this.lastResizeFullscreenResult = isFullscreen;
|
|
64
|
+
Urso.localData.set('fullscreen.isFullscreen', isFullscreen);
|
|
65
|
+
this.emit(Urso.events.COMPONENTS_FULLSCREEN_CHANGE, isFullscreen);
|
|
57
66
|
}
|
|
58
67
|
|
|
59
68
|
_subscribeOnce() {
|
|
@@ -40,6 +40,10 @@ class ComponentsFullscreenIos {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
get isFullscreen() {
|
|
44
|
+
return this._isFullscreen;
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
get _isFullscreen() {
|
|
44
48
|
const minFactor = 0.51;
|
|
45
49
|
const deviceFactor = screen.width / screen.height;
|
|
@@ -49,7 +53,7 @@ class ComponentsFullscreenIos {
|
|
|
49
53
|
|
|
50
54
|
return !(
|
|
51
55
|
this._isPortrait ?
|
|
52
|
-
factor - deviceFactor < 0.1:
|
|
56
|
+
factor - deviceFactor < 0.1 :
|
|
53
57
|
factor > minFactor
|
|
54
58
|
);
|
|
55
59
|
}
|
|
@@ -87,8 +91,8 @@ class ComponentsFullscreenIos {
|
|
|
87
91
|
this._div.style.zIndex = needShowDiv ? 1 : -1;
|
|
88
92
|
clearTimeout(this._scrollTimeout)
|
|
89
93
|
this._scrollTimeout = setTimeout(() => {
|
|
90
|
-
if(needShowDiv)
|
|
91
|
-
window.scrollTo(0,0);
|
|
94
|
+
if (needShowDiv)
|
|
95
|
+
window.scrollTo(0, 0);
|
|
92
96
|
}, 200);
|
|
93
97
|
}
|
|
94
98
|
|
package/src/js/extra/_info.js
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModulesObjectsModelsText fillCustomColors patch
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Render the text with letter-spacing.
|
|
8
|
+
*
|
|
9
|
+
* @param text - The text to draw
|
|
10
|
+
* @param x - Horizontal position to draw the text
|
|
11
|
+
* @param y - Vertical position to draw the text
|
|
12
|
+
* @param isStroke - Is this drawing for the outside stroke of the
|
|
13
|
+
* text? If not, it's for the inside fill
|
|
14
|
+
*/
|
|
15
|
+
PIXI.Text.prototype.drawLetterSpacing = function (text, x, y, isStroke) {
|
|
16
|
+
if (isStroke === void 0) { isStroke = false; }
|
|
17
|
+
var style = this._style;
|
|
18
|
+
// letterSpacing of 0 means normal
|
|
19
|
+
var letterSpacing = style.letterSpacing;
|
|
20
|
+
// Checking that we can use moddern canvas2D api
|
|
21
|
+
// https://developer.chrome.com/origintrials/#/view_trial/3585991203293757441
|
|
22
|
+
// note: this is unstable API, Chrome less 94 use a `textLetterSpacing`, newest use a letterSpacing
|
|
23
|
+
// eslint-disable-next-line max-len
|
|
24
|
+
var supportLetterSpacing = 'letterSpacing' in CanvasRenderingContext2D.prototype
|
|
25
|
+
|| 'textLetterSpacing' in CanvasRenderingContext2D.prototype;
|
|
26
|
+
|
|
27
|
+
if ((letterSpacing === 0 || supportLetterSpacing) && (!this.fillCustomColors || this.fillCustomColors.length === 0)) { //colors patch in if state
|
|
28
|
+
if (supportLetterSpacing) {
|
|
29
|
+
this.context.letterSpacing = letterSpacing;
|
|
30
|
+
this.context.textLetterSpacing = letterSpacing;
|
|
31
|
+
}
|
|
32
|
+
if (isStroke) {
|
|
33
|
+
this.context.strokeText(text, x, y);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.context.fillText(text, x, y);
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
var currentPosition = x;
|
|
41
|
+
|
|
42
|
+
var customColors = [];//colors patch block
|
|
43
|
+
var textIndexOffset = this.text.indexOf(text);
|
|
44
|
+
if (this.fillCustomColors) {
|
|
45
|
+
for (var k in this.fillCustomColors){
|
|
46
|
+
var colorsParams = this.fillCustomColors[k];
|
|
47
|
+
customColors[colorsParams.position] = colorsParams.color;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Using Array.from correctly splits characters whilst keeping emoji together.
|
|
52
|
+
// This is not supported on IE as it requires ES6, so regular text splitting occurs.
|
|
53
|
+
// This also doesn't account for emoji that are multiple emoji put together to make something else.
|
|
54
|
+
// Handling all of this would require a big library itself.
|
|
55
|
+
// https://medium.com/@giltayar/iterating-over-emoji-characters-the-es6-way-f06e4589516
|
|
56
|
+
// https://github.com/orling/grapheme-splitter
|
|
57
|
+
var stringArray = Array.from ? Array.from(text) : text.split('');
|
|
58
|
+
var previousWidth = this.context.measureText(text).width;
|
|
59
|
+
var currentWidth = 0;
|
|
60
|
+
for (var i = 0; i < stringArray.length; ++i) {
|
|
61
|
+
var currentChar = stringArray[i];
|
|
62
|
+
|
|
63
|
+
if (isStroke) {
|
|
64
|
+
this.context.strokeText(currentChar, currentPosition, y);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
if (customColors[textIndexOffset + i]) { //colors patch block
|
|
68
|
+
this.context.fillStyle = customColors[textIndexOffset + i];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.context.fillText(currentChar, currentPosition, y);
|
|
72
|
+
}
|
|
73
|
+
currentWidth = this.context.measureText(text.substring(i + 1)).width;
|
|
74
|
+
currentPosition += previousWidth - currentWidth + letterSpacing;
|
|
75
|
+
previousWidth = currentWidth;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
@@ -6,6 +6,7 @@ class ModulesAssetsService {
|
|
|
6
6
|
|
|
7
7
|
this._currentQuality = 'auto';
|
|
8
8
|
this._addedAssetsCache = [];
|
|
9
|
+
this.lazyLoadProcessStarted = false;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
getQuality() {
|
|
@@ -30,7 +31,7 @@ class ModulesAssetsService {
|
|
|
30
31
|
startLoad(callback) {
|
|
31
32
|
this.loadGroup(
|
|
32
33
|
this.getInstance('Config').loadingGroups.initial,
|
|
33
|
-
(() => { callback(); this.
|
|
34
|
+
(() => { callback(); this._startLazyLoad(); }).bind(this)
|
|
34
35
|
)
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -263,6 +264,14 @@ class ModulesAssetsService {
|
|
|
263
264
|
this.assets[model.loadingGroup].push(model);
|
|
264
265
|
}
|
|
265
266
|
|
|
267
|
+
_startLazyLoad() {
|
|
268
|
+
if (this.lazyLoadProcessStarted)
|
|
269
|
+
return;
|
|
270
|
+
|
|
271
|
+
this.lazyLoadProcessStarted = true;
|
|
272
|
+
this._continueLazyLoad();
|
|
273
|
+
}
|
|
274
|
+
|
|
266
275
|
_continueLazyLoad(step) {
|
|
267
276
|
if (!step)
|
|
268
277
|
step = 0;
|
|
@@ -20,6 +20,7 @@ class ModulesObjectsModelsText extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
20
20
|
this.fontStyle = Urso.helper.recursiveGet('fontStyle', params, false); //'italic'
|
|
21
21
|
this.fontWeight = Urso.helper.recursiveGet('fontWeight', params, false); // 'bold'
|
|
22
22
|
this.fill = Urso.helper.recursiveGet('fill', params, '#000000'); // gradient ['#ffffff', '#00ff99']
|
|
23
|
+
this.fillCustomColors = Urso.helper.recursiveGet('fillCustomColors', params, false); //or array [{position:12,color:'#000000'},...]
|
|
23
24
|
this.stroke = Urso.helper.recursiveGet('stroke', params, 'black');
|
|
24
25
|
this.strokeThickness = Urso.helper.recursiveGet('strokeThickness', params, 0);
|
|
25
26
|
this.dropShadow = Urso.helper.recursiveGet('dropShadow', params, false);
|
|
@@ -38,6 +39,10 @@ class ModulesObjectsModelsText extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
38
39
|
this._originalModel.text = this.text = Urso.i18n.get(this.localeId, this.localeVariables);
|
|
39
40
|
|
|
40
41
|
this._baseObject = new PIXI.Text(this.text);
|
|
42
|
+
|
|
43
|
+
if (this.fillCustomColors) {
|
|
44
|
+
this._baseObject.fillCustomColors = this.fillCustomColors;
|
|
45
|
+
}
|
|
41
46
|
};
|
|
42
47
|
|
|
43
48
|
_newLocaleHandler() {
|
|
@@ -161,6 +161,7 @@ class ModulesObjectsProxy {
|
|
|
161
161
|
'fontStyle': 'style.fontStyle',
|
|
162
162
|
'fontWeight': 'style.fontWeight',
|
|
163
163
|
'fill': 'style.fill',
|
|
164
|
+
'fillCustomColors': 'fillCustomColors',
|
|
164
165
|
'stroke': 'style.stroke',
|
|
165
166
|
'strokeThickness': 'style.strokeThickness',
|
|
166
167
|
'dropShadow': 'style.dropShadow',
|
|
@@ -3,6 +3,7 @@ class ModulesObserverConfig {
|
|
|
3
3
|
this.singleton = true;
|
|
4
4
|
|
|
5
5
|
this.list = {
|
|
6
|
+
COMPONENTS_FULLSCREEN_CHANGE: 'components.fullscreen.change',
|
|
6
7
|
MODULES_ASSETS_GROUP_LOADED: 'modules.assets.group.loaded',
|
|
7
8
|
MODULES_ASSETS_LOAD_PROGRESS: 'modules.assets.load.progress',
|
|
8
9
|
MODULES_ASSETS_LAZYLOAD_FINISHED: 'modules.assets.lazyLoad.finished',
|
|
@@ -28,6 +29,8 @@ class ModulesObserverConfig {
|
|
|
28
29
|
MODULES_SCENES_DISPLAY_START: 'modules.scenes.display.start',
|
|
29
30
|
MODULES_SCENES_DISPLAY_FINISHED: 'modules.scenes.display.finished',
|
|
30
31
|
MODULES_SCENES_MOUSE_NEW_POSITION: 'modules.scenes.mouse.newPosition',
|
|
32
|
+
MODULES_SCENES_PAUSE: 'modules.scenes.pause',
|
|
33
|
+
MODULES_SCENES_RESUME: 'modules.scenes.resume',
|
|
31
34
|
MODULES_SCENES_UPDATE: 'modules.scenes.update',
|
|
32
35
|
EXTRA_BROWSEREVENTS_WINDOW_PRE_RESIZE: 'extra.browserEvents.window.pre.resize',
|
|
33
36
|
EXTRA_BROWSEREVENTS_WINDOW_RESIZE: 'extra.browserEvents.window.resize',
|
|
@@ -26,6 +26,7 @@ class ModulesScenesService {
|
|
|
26
26
|
*/
|
|
27
27
|
pause() {
|
|
28
28
|
this.getInstance('PixiWrapper').pause();
|
|
29
|
+
this.emit(Urso.events.MODULES_SCENES_PAUSE);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
@@ -33,6 +34,7 @@ class ModulesScenesService {
|
|
|
33
34
|
*/
|
|
34
35
|
resume() {
|
|
35
36
|
this.getInstance('PixiWrapper').resume();
|
|
37
|
+
this.emit(Urso.events.MODULES_SCENES_RESUME);
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
/**
|