@vnejs/module.controller.hide.on.controls 0.2.2 → 0.2.4

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 CHANGED
@@ -9,9 +9,10 @@ export declare abstract class ModuleControllerHideOnControls<TEvents extends Mod
9
9
  IS_BACK_ENABLED: boolean;
10
10
  IS_MENU_ENABLED: boolean;
11
11
  IS_GAMEMENU_ENABLED: boolean;
12
- emitHide: () => Promise<unknown[]> | undefined;
13
- get controls(): Record<string, () => void>;
12
+ isShow: boolean;
13
+ emitHide: () => Promise<import("@vnejs/shared").EmitResults<string>> | undefined;
14
+ get CONTROLS(): Record<string, () => void>;
14
15
  subscribe: () => void;
15
- onShow: () => Promise<unknown[]> | undefined;
16
- onHide: () => Promise<unknown[]> | undefined;
16
+ onShow: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:push">> | undefined;
17
+ onHide: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:pop">> | undefined;
17
18
  }
package/dist/index.js CHANGED
@@ -3,8 +3,9 @@ export class ModuleControllerHideOnControls extends ModuleCore {
3
3
  IS_BACK_ENABLED = true;
4
4
  IS_MENU_ENABLED = true;
5
5
  IS_GAMEMENU_ENABLED = true;
6
+ isShow = false;
6
7
  emitHide = () => this.emit(this.EVENT_HIDE);
7
- get controls() {
8
+ get CONTROLS() {
8
9
  const controls = {};
9
10
  if (this.IS_BACK_ENABLED)
10
11
  controls[this.CONST.CONTROLS.BUTTONS.BACK] = () => void this.emitHide();
@@ -18,11 +19,21 @@ export class ModuleControllerHideOnControls extends ModuleCore {
18
19
  this.on(this.EVENT_SHOW, this.onShow);
19
20
  this.on(this.EVENT_HIDE, this.onHide);
20
21
  };
21
- onShow = () => this.emit(this.EVENTS.CONTROLS.PUSH, {
22
- key: this.name,
23
- controls: this.controls,
24
- index: this.CONTROLS_ZINDEX + 1,
25
- checkNext: true,
26
- });
27
- onHide = () => this.emit(this.EVENTS.CONTROLS.POP, { key: this.name });
22
+ onShow = () => {
23
+ if (this.isShow)
24
+ return;
25
+ this.isShow = true;
26
+ return this.emit(this.EVENTS.CONTROLS.PUSH, {
27
+ key: this.name,
28
+ controls: this.CONTROLS,
29
+ index: this.CONTROLS_ZINDEX + 1,
30
+ checkNext: true,
31
+ });
32
+ };
33
+ onHide = () => {
34
+ if (!this.isShow)
35
+ return;
36
+ this.isShow = false;
37
+ return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name });
38
+ };
28
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/module.controller.hide.on.controls",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -33,9 +33,11 @@ export abstract class ModuleControllerHideOnControls<
33
33
  IS_MENU_ENABLED = true;
34
34
  IS_GAMEMENU_ENABLED = true;
35
35
 
36
+ isShow = false;
37
+
36
38
  emitHide = () => this.emit(this.EVENT_HIDE);
37
39
 
38
- get controls() {
40
+ get CONTROLS() {
39
41
  const controls: Record<string, () => void> = {};
40
42
 
41
43
  if (this.IS_BACK_ENABLED) controls[this.CONST.CONTROLS.BUTTONS.BACK] = () => void this.emitHide();
@@ -50,13 +52,24 @@ export abstract class ModuleControllerHideOnControls<
50
52
  this.on(this.EVENT_HIDE, this.onHide);
51
53
  };
52
54
 
53
- onShow = () =>
54
- this.emit(this.EVENTS.CONTROLS.PUSH, {
55
+ onShow = () => {
56
+ if (this.isShow) return;
57
+
58
+ this.isShow = true;
59
+
60
+ return this.emit(this.EVENTS.CONTROLS.PUSH, {
55
61
  key: this.name,
56
- controls: this.controls,
62
+ controls: this.CONTROLS,
57
63
  index: this.CONTROLS_ZINDEX + 1,
58
64
  checkNext: true,
59
65
  } satisfies ControlsPushPayload);
66
+ };
60
67
 
61
- onHide = () => this.emit(this.EVENTS.CONTROLS.POP, { key: this.name } satisfies ControlsPopPayload);
68
+ onHide = () => {
69
+ if (!this.isShow) return;
70
+
71
+ this.isShow = false;
72
+
73
+ return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name } satisfies ControlsPopPayload);
74
+ };
62
75
  }