@vnejs/module.controller.bg 0.2.5 → 0.2.6
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/dist/index.d.ts +2 -2
- package/dist/index.js +11 -11
- package/package.json +1 -1
- package/src/index.ts +14 -13
package/dist/index.d.ts
CHANGED
|
@@ -18,8 +18,8 @@ export declare abstract class ModuleControllerBg<TEvents extends ModuleControlle
|
|
|
18
18
|
IS_MEMORY_CLEARED_UPDATE_ENABLED: boolean;
|
|
19
19
|
subscribe: () => void;
|
|
20
20
|
start: () => Promise<HTMLImageElement> | undefined;
|
|
21
|
-
getDefaultState: () => TState;
|
|
22
21
|
onShowBefore: () => Promise<void>;
|
|
23
|
-
onMemoryCleared: () => Promise<void>;
|
|
24
22
|
loadBg: () => Promise<HTMLImageElement>;
|
|
23
|
+
onMemoryCleared: () => Promise<void>;
|
|
24
|
+
getDefaultState: () => TState;
|
|
25
25
|
}
|
package/dist/index.js
CHANGED
|
@@ -21,11 +21,20 @@ export class ModuleControllerBg extends ModuleCore {
|
|
|
21
21
|
if (this.IS_START_PRELOAD_ENABLED)
|
|
22
22
|
return this.loadBg();
|
|
23
23
|
};
|
|
24
|
-
getDefaultState = () => ({ isShow: false });
|
|
25
24
|
onShowBefore = async () => {
|
|
26
25
|
const media = await this.loadBg();
|
|
27
26
|
await this.emit(this.EVENT_UPDATE_STATE, { bgSrc: media.src });
|
|
28
27
|
};
|
|
28
|
+
loadBg = () => {
|
|
29
|
+
const [type, priority] = [this.CONST.MEDIA.TYPES.IMAGE, this.CONST.MEDIA.PRIORITIES.HIGH];
|
|
30
|
+
return this.emitOne(this.EVENTS.MEDIA.LOAD, {
|
|
31
|
+
type,
|
|
32
|
+
priority,
|
|
33
|
+
quality: this.shared.settings[this.QUALITY_SETTING],
|
|
34
|
+
name: `${this.MEDIA_PREFIX}${this.BGNAME}`,
|
|
35
|
+
mediaType: this.MEDIA_TYPE,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
29
38
|
onMemoryCleared = async () => {
|
|
30
39
|
if (this.IS_MEMORY_CLEARED_UPDATE_ENABLED && this.state.isShow) {
|
|
31
40
|
const media = await this.loadBg();
|
|
@@ -38,14 +47,5 @@ export class ModuleControllerBg extends ModuleCore {
|
|
|
38
47
|
if (this.IS_MEMORY_CLEARED_PRELOAD_ENABLED)
|
|
39
48
|
await this.loadBg();
|
|
40
49
|
};
|
|
41
|
-
|
|
42
|
-
const [type, priority] = [this.CONST.MEDIA.TYPES.IMAGE, this.CONST.MEDIA.PRIORITIES.HIGH];
|
|
43
|
-
return this.emitOne(this.EVENTS.MEDIA.LOAD, {
|
|
44
|
-
type,
|
|
45
|
-
priority,
|
|
46
|
-
quality: this.shared.settings[this.QUALITY_SETTING],
|
|
47
|
-
name: `${this.MEDIA_PREFIX}${this.BGNAME}`,
|
|
48
|
-
mediaType: this.MEDIA_TYPE,
|
|
49
|
-
});
|
|
50
|
-
};
|
|
50
|
+
getDefaultState = () => ({ isShow: false });
|
|
51
51
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ export abstract class ModuleControllerBg<
|
|
|
32
32
|
EVENT_PRELOAD?: string;
|
|
33
33
|
|
|
34
34
|
abstract BGNAME: string;
|
|
35
|
+
|
|
35
36
|
abstract QUALITY_SETTING: string;
|
|
36
37
|
|
|
37
38
|
MEDIA_PREFIX = "bg/";
|
|
@@ -59,14 +60,24 @@ export abstract class ModuleControllerBg<
|
|
|
59
60
|
if (this.IS_START_PRELOAD_ENABLED) return this.loadBg();
|
|
60
61
|
};
|
|
61
62
|
|
|
62
|
-
getDefaultState = (): TState => ({ isShow: false }) as TState;
|
|
63
|
-
|
|
64
63
|
onShowBefore = async () => {
|
|
65
64
|
const media = await this.loadBg();
|
|
66
65
|
|
|
67
66
|
await this.emit(this.EVENT_UPDATE_STATE, { bgSrc: media.src });
|
|
68
67
|
};
|
|
69
68
|
|
|
69
|
+
loadBg = () => {
|
|
70
|
+
const [type, priority] = [this.CONST.MEDIA.TYPES.IMAGE, this.CONST.MEDIA.PRIORITIES.HIGH];
|
|
71
|
+
|
|
72
|
+
return this.emitOne(this.EVENTS.MEDIA.LOAD, {
|
|
73
|
+
type,
|
|
74
|
+
priority,
|
|
75
|
+
quality: this.shared.settings[this.QUALITY_SETTING] as string | number,
|
|
76
|
+
name: `${this.MEDIA_PREFIX}${this.BGNAME}`,
|
|
77
|
+
mediaType: this.MEDIA_TYPE,
|
|
78
|
+
}) as Promise<HTMLImageElement>;
|
|
79
|
+
};
|
|
80
|
+
|
|
70
81
|
onMemoryCleared = async () => {
|
|
71
82
|
if (this.IS_MEMORY_CLEARED_UPDATE_ENABLED && this.state.isShow) {
|
|
72
83
|
const media = await this.loadBg();
|
|
@@ -81,15 +92,5 @@ export abstract class ModuleControllerBg<
|
|
|
81
92
|
if (this.IS_MEMORY_CLEARED_PRELOAD_ENABLED) await this.loadBg();
|
|
82
93
|
};
|
|
83
94
|
|
|
84
|
-
|
|
85
|
-
const [type, priority] = [this.CONST.MEDIA.TYPES.IMAGE, this.CONST.MEDIA.PRIORITIES.HIGH];
|
|
86
|
-
|
|
87
|
-
return this.emitOne(this.EVENTS.MEDIA.LOAD, {
|
|
88
|
-
type,
|
|
89
|
-
priority,
|
|
90
|
-
quality: this.shared.settings[this.QUALITY_SETTING] as string | number,
|
|
91
|
-
name: `${this.MEDIA_PREFIX}${this.BGNAME}`,
|
|
92
|
-
mediaType: this.MEDIA_TYPE,
|
|
93
|
-
}) as Promise<HTMLImageElement>;
|
|
94
|
-
};
|
|
95
|
+
getDefaultState = (): TState => ({ isShow: false }) as TState;
|
|
95
96
|
}
|