@vnejs/module.controller.arrows.horizontal 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 +3 -1
- package/dist/index.js +6 -2
- package/package.json +1 -1
- package/src/index.ts +7 -3
package/dist/index.d.ts
CHANGED
|
@@ -16,8 +16,10 @@ export declare abstract class ModuleControllerArrowsHorizontal<TEvents extends M
|
|
|
16
16
|
maxCurrentItem: number;
|
|
17
17
|
subscribe: () => void;
|
|
18
18
|
getDefaultState: () => TState;
|
|
19
|
-
|
|
19
|
+
getMaxCurrentItem: () => number | Promise<number>;
|
|
20
20
|
isArrowItemAvailable: (_index: number) => boolean | Promise<boolean>;
|
|
21
|
+
onArrowLeft: () => void | Promise<void>;
|
|
22
|
+
onArrowRight: () => void | Promise<void>;
|
|
21
23
|
onShow: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:push">> | undefined;
|
|
22
24
|
onHide: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:pop">> | undefined;
|
|
23
25
|
incCurrentItem: () => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ModuleCore } from "@vnejs/module.core";
|
|
2
2
|
export class ModuleControllerArrowsHorizontal extends ModuleCore {
|
|
3
3
|
CONTROLS = {
|
|
4
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.
|
|
5
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.
|
|
4
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.onArrowLeft(),
|
|
5
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.onArrowRight(),
|
|
6
6
|
};
|
|
7
7
|
currentItem = null;
|
|
8
8
|
maxCurrentItem = 0;
|
|
@@ -10,9 +10,13 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
|
|
|
10
10
|
const { SHOW, HIDE } = this.CONST.COMPONENTS.LIFECYCLE_PRIORITY;
|
|
11
11
|
this.on(this.EVENT_SHOW, this.onShow, { priority: SHOW.CONTROLS });
|
|
12
12
|
this.on(this.EVENT_HIDE, this.onHide, { priority: HIDE.CONTROLS });
|
|
13
|
+
this.on(this.EVENT_UPDATE_STATE, this.updateState);
|
|
13
14
|
};
|
|
14
15
|
getDefaultState = () => ({ isShow: false });
|
|
16
|
+
getMaxCurrentItem = () => 0;
|
|
15
17
|
isArrowItemAvailable = (_index) => true;
|
|
18
|
+
onArrowLeft = () => void this.decCurrentItem();
|
|
19
|
+
onArrowRight = () => void this.incCurrentItem();
|
|
16
20
|
onShow = () => {
|
|
17
21
|
this.updateState({ isShow: true });
|
|
18
22
|
this.currentItem = null;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -34,8 +34,8 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
34
34
|
abstract CONTROLS_ZINDEX: number;
|
|
35
35
|
|
|
36
36
|
CONTROLS = {
|
|
37
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.
|
|
38
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.
|
|
37
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.onArrowLeft(),
|
|
38
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.onArrowRight(),
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
currentItem: number | null = null;
|
|
@@ -46,14 +46,18 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
46
46
|
|
|
47
47
|
this.on(this.EVENT_SHOW, this.onShow, { priority: SHOW.CONTROLS });
|
|
48
48
|
this.on(this.EVENT_HIDE, this.onHide, { priority: HIDE.CONTROLS });
|
|
49
|
+
this.on(this.EVENT_UPDATE_STATE, this.updateState);
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
getDefaultState = (): TState => ({ isShow: false }) as TState;
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
getMaxCurrentItem = (): number | Promise<number> => 0;
|
|
54
55
|
|
|
55
56
|
isArrowItemAvailable = (_index: number): boolean | Promise<boolean> => true;
|
|
56
57
|
|
|
58
|
+
onArrowLeft = (): void | Promise<void> => void this.decCurrentItem();
|
|
59
|
+
onArrowRight = (): void | Promise<void> => void this.incCurrentItem();
|
|
60
|
+
|
|
57
61
|
onShow = () => {
|
|
58
62
|
this.updateState({ isShow: true } as Partial<TState>);
|
|
59
63
|
this.currentItem = null;
|