@vnejs/module.controller.arrows.horizontal 0.2.8 → 0.2.9
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 +4 -4
- package/dist/index.js +8 -8
- package/package.json +1 -1
- package/src/index.ts +9 -17
package/dist/index.d.ts
CHANGED
|
@@ -15,18 +15,18 @@ export declare abstract class ModuleControllerArrowsHorizontal<TEvents extends M
|
|
|
15
15
|
currentItem: number | null;
|
|
16
16
|
maxCurrentItem: number;
|
|
17
17
|
subscribe: () => void;
|
|
18
|
+
onShow: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:push">> | undefined;
|
|
19
|
+
onHide: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:pop">> | undefined;
|
|
20
|
+
onHideCleanup: () => Promise<import("@vnejs/shared").EmitResults<string> | undefined>;
|
|
21
|
+
emitCurrentItem: () => void;
|
|
18
22
|
getMaxCurrentItem: () => number | Promise<number>;
|
|
19
23
|
isArrowItemAvailable: (_index: number) => boolean | Promise<boolean>;
|
|
20
24
|
onArrowLeft: () => void | Promise<void>;
|
|
21
25
|
onArrowRight: () => void | Promise<void>;
|
|
22
|
-
onShow: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:push">> | undefined;
|
|
23
|
-
onHide: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:pop">> | undefined;
|
|
24
|
-
onHideCleanup: () => Promise<import("@vnejs/shared").EmitResults<string> | undefined>;
|
|
25
26
|
incCurrentItem: () => Promise<void>;
|
|
26
27
|
decCurrentItem: () => Promise<void>;
|
|
27
28
|
setCurrentItem: (value: number, defaultValue: number, direction?: 1 | -1) => Promise<void>;
|
|
28
29
|
applyCurrentItem: (value: number, defaultValue: number) => void;
|
|
29
30
|
skipUnavailableItems: (direction: 1 | -1) => Promise<void>;
|
|
30
|
-
emitCurrentItem: () => void;
|
|
31
31
|
syncMaxCurrentItem: () => Promise<void>;
|
|
32
32
|
}
|
package/dist/index.js
CHANGED
|
@@ -13,10 +13,6 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
|
|
|
13
13
|
this.on(this.EVENT_HIDE, this.onHideCleanup, { priority: HIDE.CLEANUP });
|
|
14
14
|
this.on(this.EVENT_UPDATE_STATE, this.updateState);
|
|
15
15
|
};
|
|
16
|
-
getMaxCurrentItem = () => 0;
|
|
17
|
-
isArrowItemAvailable = (_index) => true;
|
|
18
|
-
onArrowLeft = () => void this.decCurrentItem();
|
|
19
|
-
onArrowRight = () => void this.incCurrentItem();
|
|
20
16
|
onShow = () => {
|
|
21
17
|
this.currentItem = null;
|
|
22
18
|
return this.emit(this.EVENTS.CONTROLS.PUSH, {
|
|
@@ -36,6 +32,14 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
|
|
|
36
32
|
await this.emit(this.EVENT_UPDATE_STATE, unset);
|
|
37
33
|
return this.emit(this.EVENT_UPDATE_FAST);
|
|
38
34
|
};
|
|
35
|
+
emitCurrentItem = () => {
|
|
36
|
+
this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem });
|
|
37
|
+
this.emit(this.EVENT_UPDATE_FAST);
|
|
38
|
+
};
|
|
39
|
+
getMaxCurrentItem = () => 0;
|
|
40
|
+
isArrowItemAvailable = (_index) => true;
|
|
41
|
+
onArrowLeft = () => void this.decCurrentItem();
|
|
42
|
+
onArrowRight = () => void this.incCurrentItem();
|
|
39
43
|
incCurrentItem = async () => {
|
|
40
44
|
await this.syncMaxCurrentItem();
|
|
41
45
|
return this.setCurrentItem((this.currentItem ?? 0) + 1, 0, 1);
|
|
@@ -71,10 +75,6 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
|
|
|
71
75
|
break;
|
|
72
76
|
}
|
|
73
77
|
};
|
|
74
|
-
emitCurrentItem = () => {
|
|
75
|
-
this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem });
|
|
76
|
-
this.emit(this.EVENT_UPDATE_FAST);
|
|
77
|
-
};
|
|
78
78
|
syncMaxCurrentItem = async () => {
|
|
79
79
|
this.maxCurrentItem = await this.getMaxCurrentItem();
|
|
80
80
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -32,7 +32,6 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
32
32
|
abstract EVENT_UPDATE_FAST: string;
|
|
33
33
|
|
|
34
34
|
abstract CONTROLS_ZINDEX: number;
|
|
35
|
-
|
|
36
35
|
CONTROLS = {
|
|
37
36
|
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.onArrowLeft(),
|
|
38
37
|
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.onArrowRight(),
|
|
@@ -50,13 +49,6 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
50
49
|
this.on(this.EVENT_UPDATE_STATE, this.updateState);
|
|
51
50
|
};
|
|
52
51
|
|
|
53
|
-
getMaxCurrentItem = (): number | Promise<number> => 0;
|
|
54
|
-
|
|
55
|
-
isArrowItemAvailable = (_index: number): boolean | Promise<boolean> => true;
|
|
56
|
-
|
|
57
|
-
onArrowLeft = (): void | Promise<void> => void this.decCurrentItem();
|
|
58
|
-
onArrowRight = (): void | Promise<void> => void this.incCurrentItem();
|
|
59
|
-
|
|
60
52
|
onShow = () => {
|
|
61
53
|
this.currentItem = null;
|
|
62
54
|
|
|
@@ -84,6 +76,15 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
84
76
|
return this.emit(this.EVENT_UPDATE_FAST);
|
|
85
77
|
};
|
|
86
78
|
|
|
79
|
+
emitCurrentItem = () => {
|
|
80
|
+
this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem } satisfies Partial<ModuleControllerArrowsHorizontalState>);
|
|
81
|
+
this.emit(this.EVENT_UPDATE_FAST);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
getMaxCurrentItem = (): number | Promise<number> => 0;
|
|
85
|
+
isArrowItemAvailable = (_index: number): boolean | Promise<boolean> => true;
|
|
86
|
+
onArrowLeft = (): void | Promise<void> => void this.decCurrentItem();
|
|
87
|
+
onArrowRight = (): void | Promise<void> => void this.incCurrentItem();
|
|
87
88
|
incCurrentItem = async () => {
|
|
88
89
|
await this.syncMaxCurrentItem();
|
|
89
90
|
|
|
@@ -94,13 +95,11 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
94
95
|
|
|
95
96
|
return this.setCurrentItem((this.currentItem ?? 0) - 1, this.maxCurrentItem, -1);
|
|
96
97
|
};
|
|
97
|
-
|
|
98
98
|
setCurrentItem = async (value: number, defaultValue: number, direction: 1 | -1 = 1) => {
|
|
99
99
|
this.applyCurrentItem(value, defaultValue);
|
|
100
100
|
await this.skipUnavailableItems(direction);
|
|
101
101
|
this.emitCurrentItem();
|
|
102
102
|
};
|
|
103
|
-
|
|
104
103
|
applyCurrentItem = (value: number, defaultValue: number) => {
|
|
105
104
|
if (this.currentItem === null) {
|
|
106
105
|
this.currentItem = defaultValue;
|
|
@@ -110,7 +109,6 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
110
109
|
if (this.currentItem < 0) this.currentItem = this.maxCurrentItem;
|
|
111
110
|
}
|
|
112
111
|
};
|
|
113
|
-
|
|
114
112
|
skipUnavailableItems = async (direction: 1 | -1) => {
|
|
115
113
|
if (this.currentItem === null) return;
|
|
116
114
|
|
|
@@ -121,12 +119,6 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
121
119
|
if (this.currentItem === start) break;
|
|
122
120
|
}
|
|
123
121
|
};
|
|
124
|
-
|
|
125
|
-
emitCurrentItem = () => {
|
|
126
|
-
this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem } satisfies Partial<ModuleControllerArrowsHorizontalState>);
|
|
127
|
-
this.emit(this.EVENT_UPDATE_FAST);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
122
|
syncMaxCurrentItem = async () => {
|
|
131
123
|
this.maxCurrentItem = await this.getMaxCurrentItem();
|
|
132
124
|
};
|