@egjs/flicking-plugins 4.7.1 → 4.8.0-beta.1
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/declaration/Arrow.d.ts +51 -45
- package/declaration/AutoPlay.d.ts +44 -40
- package/declaration/Fade.d.ts +16 -16
- package/declaration/Parallax.d.ts +16 -16
- package/declaration/Perspective.d.ts +28 -28
- package/declaration/Sync.d.ts +37 -37
- package/declaration/const.d.ts +31 -31
- package/declaration/event.d.ts +5 -5
- package/declaration/index.d.ts +10 -10
- package/declaration/pagination/Pagination.d.ts +61 -61
- package/declaration/pagination/index.d.ts +3 -3
- package/declaration/pagination/renderer/BulletRenderer.d.ts +11 -11
- package/declaration/pagination/renderer/FractionRenderer.d.ts +9 -9
- package/declaration/pagination/renderer/Renderer.d.ts +19 -19
- package/declaration/pagination/renderer/ScrollBulletRenderer.d.ts +12 -12
- package/declaration/type.d.ts +9 -9
- package/declaration/utils.d.ts +3 -3
- package/dist/plugins.esm.js +124 -75
- package/dist/plugins.esm.js.map +1 -1
- package/dist/plugins.js +124 -75
- package/dist/plugins.js.map +1 -1
- package/dist/plugins.min.js +2 -2
- package/dist/plugins.min.js.map +1 -1
- package/package.json +3 -3
- package/src/Arrow.ts +37 -13
- package/src/AutoPlay.ts +10 -1
package/src/Arrow.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Flicking, { EVENTS, FlickingError, Plugin } from "@egjs/flicking";
|
|
1
|
+
import Flicking, { EVENTS, FlickingError, Plugin, WillChangeEvent } from "@egjs/flicking";
|
|
2
2
|
|
|
3
3
|
import { BROWSER } from "./event";
|
|
4
4
|
import { ARROW } from "./const";
|
|
@@ -11,6 +11,7 @@ interface ArrowOptions {
|
|
|
11
11
|
disabledClass: string;
|
|
12
12
|
moveCount: number;
|
|
13
13
|
moveByViewportSize: boolean;
|
|
14
|
+
interruptable: boolean;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -23,6 +24,7 @@ class Arrow implements Plugin {
|
|
|
23
24
|
private _flicking: Flicking | null = null;
|
|
24
25
|
private _prevEl: HTMLElement;
|
|
25
26
|
private _nextEl: HTMLElement;
|
|
27
|
+
private _nextIndex: number;
|
|
26
28
|
|
|
27
29
|
/* Options */
|
|
28
30
|
private _parentEl: ArrowOptions["parentEl"];
|
|
@@ -31,6 +33,7 @@ class Arrow implements Plugin {
|
|
|
31
33
|
private _disabledClass: ArrowOptions["disabledClass"];
|
|
32
34
|
private _moveCount: ArrowOptions["moveCount"];
|
|
33
35
|
private _moveByViewportSize: ArrowOptions["moveByViewportSize"];
|
|
36
|
+
private _interruptable: ArrowOptions["interruptable"];
|
|
34
37
|
|
|
35
38
|
public get prevEl() { return this._prevEl; }
|
|
36
39
|
public get nextEl() { return this._nextEl; }
|
|
@@ -41,6 +44,7 @@ class Arrow implements Plugin {
|
|
|
41
44
|
public get disabledClass() { return this._disabledClass; }
|
|
42
45
|
public get moveCount() { return this._moveCount; }
|
|
43
46
|
public get moveByViewportSize() { return this._moveByViewportSize; }
|
|
47
|
+
public get interruptable() { return this._interruptable; }
|
|
44
48
|
|
|
45
49
|
public set parentEl(val: ArrowOptions["parentEl"]) { this._parentEl = val; }
|
|
46
50
|
public set prevElSelector(val: ArrowOptions["prevElSelector"]) { this._prevElSelector = val; }
|
|
@@ -48,6 +52,7 @@ class Arrow implements Plugin {
|
|
|
48
52
|
public set disabledClass(val: ArrowOptions["disabledClass"]) { this._disabledClass = val; }
|
|
49
53
|
public set moveCount(val: ArrowOptions["moveCount"]) { this._moveCount = val; }
|
|
50
54
|
public set moveByViewportSize(val: ArrowOptions["moveByViewportSize"]) { this._moveByViewportSize = val; }
|
|
55
|
+
public set interruptable(val: ArrowOptions["interruptable"]) { this._interruptable = val; }
|
|
51
56
|
|
|
52
57
|
public constructor({
|
|
53
58
|
parentEl = null,
|
|
@@ -55,7 +60,8 @@ class Arrow implements Plugin {
|
|
|
55
60
|
nextElSelector = ARROW.NEXT_SELECTOR,
|
|
56
61
|
disabledClass = ARROW.DISABLED_CLASS,
|
|
57
62
|
moveCount = 1,
|
|
58
|
-
moveByViewportSize = false
|
|
63
|
+
moveByViewportSize = false,
|
|
64
|
+
interruptable = false
|
|
59
65
|
}: Partial<ArrowOptions> = {}) {
|
|
60
66
|
this._parentEl = parentEl;
|
|
61
67
|
this._prevElSelector = prevElSelector;
|
|
@@ -63,6 +69,7 @@ class Arrow implements Plugin {
|
|
|
63
69
|
this._disabledClass = disabledClass;
|
|
64
70
|
this._moveCount = moveCount;
|
|
65
71
|
this._moveByViewportSize = moveByViewportSize;
|
|
72
|
+
this._interruptable = interruptable;
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
public init(flicking: Flicking): void {
|
|
@@ -73,6 +80,7 @@ class Arrow implements Plugin {
|
|
|
73
80
|
this._flicking = flicking;
|
|
74
81
|
|
|
75
82
|
flicking.on(EVENTS.MOVE, this._onAnimation);
|
|
83
|
+
flicking.on(EVENTS.WILL_CHANGE, this._onWillChange);
|
|
76
84
|
|
|
77
85
|
const parentEl = this._parentEl ? this._parentEl : flicking.element;
|
|
78
86
|
const prevEl = getElement(this._prevElSelector, parentEl, "Arrow");
|
|
@@ -100,6 +108,7 @@ class Arrow implements Plugin {
|
|
|
100
108
|
}
|
|
101
109
|
|
|
102
110
|
flicking.off(EVENTS.MOVE, this._onAnimation);
|
|
111
|
+
flicking.off(EVENTS.WILL_CHANGE, this._onWillChange);
|
|
103
112
|
|
|
104
113
|
const prevEl = this._prevEl;
|
|
105
114
|
const nextEl = this._nextEl;
|
|
@@ -124,10 +133,16 @@ class Arrow implements Plugin {
|
|
|
124
133
|
|
|
125
134
|
private _onPrevClick = () => {
|
|
126
135
|
const flicking = this._flicking!;
|
|
136
|
+
const index = flicking.animating ? this._nextIndex : flicking.index;
|
|
137
|
+
const currentPanel = flicking.animating ? flicking.panels[this._nextIndex] : flicking.currentPanel;
|
|
127
138
|
const camera = flicking.camera;
|
|
128
139
|
const anchorPoints = camera.anchorPoints;
|
|
129
140
|
|
|
130
|
-
if (flicking.animating || anchorPoints.length <= 0) return;
|
|
141
|
+
if ((flicking.animating && !this.interruptable) || anchorPoints.length <= 0) return;
|
|
142
|
+
|
|
143
|
+
if (flicking.animating) {
|
|
144
|
+
flicking.stopAnimation();
|
|
145
|
+
}
|
|
131
146
|
|
|
132
147
|
const firstAnchor = anchorPoints[0];
|
|
133
148
|
const moveCount = this._moveCount;
|
|
@@ -137,18 +152,18 @@ class Arrow implements Plugin {
|
|
|
137
152
|
.catch(this._onCatch);
|
|
138
153
|
} else {
|
|
139
154
|
if (flicking.circularEnabled) {
|
|
140
|
-
let targetPanel =
|
|
155
|
+
let targetPanel = currentPanel;
|
|
141
156
|
|
|
142
157
|
for (let i = 0; i < moveCount; i++) {
|
|
143
158
|
targetPanel = targetPanel.prev()!;
|
|
144
159
|
}
|
|
145
160
|
|
|
146
161
|
targetPanel.focus().catch(this._onCatch);
|
|
147
|
-
} else if (
|
|
148
|
-
flicking.moveTo(Math.max(
|
|
162
|
+
} else if (index > firstAnchor.panel.index) {
|
|
163
|
+
flicking.moveTo(Math.max(index - moveCount, firstAnchor.panel.index))
|
|
149
164
|
.catch(this._onCatch);
|
|
150
165
|
} else if (camera.position > camera.range.min) {
|
|
151
|
-
flicking.moveTo(
|
|
166
|
+
flicking.moveTo(index)
|
|
152
167
|
.catch(this._onCatch);
|
|
153
168
|
}
|
|
154
169
|
}
|
|
@@ -156,11 +171,16 @@ class Arrow implements Plugin {
|
|
|
156
171
|
|
|
157
172
|
private _onNextClick = () => {
|
|
158
173
|
const flicking = this._flicking!;
|
|
159
|
-
|
|
174
|
+
const index = flicking.animating ? this._nextIndex : flicking.index;
|
|
175
|
+
const currentPanel = flicking.animating ? flicking.panels[this._nextIndex] : flicking.currentPanel;
|
|
160
176
|
const camera = flicking.camera;
|
|
161
177
|
const anchorPoints = camera.anchorPoints;
|
|
162
178
|
|
|
163
|
-
if (flicking.animating || anchorPoints.length <= 0) return;
|
|
179
|
+
if ((flicking.animating && !this.interruptable) || anchorPoints.length <= 0) return;
|
|
180
|
+
|
|
181
|
+
if (flicking.animating) {
|
|
182
|
+
flicking.stopAnimation();
|
|
183
|
+
}
|
|
164
184
|
|
|
165
185
|
const lastAnchor = anchorPoints[anchorPoints.length - 1];
|
|
166
186
|
const moveCount = this._moveCount;
|
|
@@ -170,18 +190,18 @@ class Arrow implements Plugin {
|
|
|
170
190
|
.catch(this._onCatch);
|
|
171
191
|
} else {
|
|
172
192
|
if (flicking.circularEnabled) {
|
|
173
|
-
let targetPanel =
|
|
193
|
+
let targetPanel = currentPanel;
|
|
174
194
|
|
|
175
195
|
for (let i = 0; i < moveCount; i++) {
|
|
176
196
|
targetPanel = targetPanel.next()!;
|
|
177
197
|
}
|
|
178
198
|
|
|
179
199
|
targetPanel.focus().catch(this._onCatch);
|
|
180
|
-
} else if (
|
|
181
|
-
flicking.moveTo(Math.min(
|
|
200
|
+
} else if (index < lastAnchor.panel.index) {
|
|
201
|
+
flicking.moveTo(Math.min(index + moveCount, lastAnchor.panel.index))
|
|
182
202
|
.catch(this._onCatch);
|
|
183
203
|
} else if (camera.position > camera.range.min) {
|
|
184
|
-
flicking.moveTo(
|
|
204
|
+
flicking.moveTo(index)
|
|
185
205
|
.catch(this._onCatch);
|
|
186
206
|
}
|
|
187
207
|
}
|
|
@@ -199,6 +219,10 @@ class Arrow implements Plugin {
|
|
|
199
219
|
}
|
|
200
220
|
};
|
|
201
221
|
|
|
222
|
+
private _onWillChange = (e: WillChangeEvent) => {
|
|
223
|
+
this._nextIndex = e.index;
|
|
224
|
+
};
|
|
225
|
+
|
|
202
226
|
private _updateClass(pos: number) {
|
|
203
227
|
const flicking = this._flicking!;
|
|
204
228
|
const disabledClass = this._disabledClass;
|
package/src/AutoPlay.ts
CHANGED
|
@@ -5,6 +5,7 @@ interface AutoPlayOptions {
|
|
|
5
5
|
animationDuration: number | undefined;
|
|
6
6
|
direction: typeof DIRECTION["NEXT"] | typeof DIRECTION["PREV"];
|
|
7
7
|
stopOnHover: boolean;
|
|
8
|
+
stopOnInit: boolean;
|
|
8
9
|
delayAfterHover: number;
|
|
9
10
|
}
|
|
10
11
|
|
|
@@ -19,6 +20,7 @@ class AutoPlay implements Plugin {
|
|
|
19
20
|
private _animationDuration: AutoPlayOptions["animationDuration"];
|
|
20
21
|
private _direction: AutoPlayOptions["direction"];
|
|
21
22
|
private _stopOnHover: AutoPlayOptions["stopOnHover"];
|
|
23
|
+
private _stopOnInit: AutoPlayOptions["stopOnInit"];
|
|
22
24
|
private _delayAfterHover: AutoPlayOptions["delayAfterHover"];
|
|
23
25
|
|
|
24
26
|
/* Internal Values */
|
|
@@ -31,6 +33,7 @@ class AutoPlay implements Plugin {
|
|
|
31
33
|
public get animationDuration() { return this._animationDuration; }
|
|
32
34
|
public get direction() { return this._direction; }
|
|
33
35
|
public get stopOnHover() { return this._stopOnHover; }
|
|
36
|
+
public get stopOnInit() { return this._stopOnInit; }
|
|
34
37
|
public get delayAfterHover() { return this._delayAfterHover; }
|
|
35
38
|
public get playing() { return this._playing; }
|
|
36
39
|
|
|
@@ -38,6 +41,7 @@ class AutoPlay implements Plugin {
|
|
|
38
41
|
public set animationDuration(val: number | undefined) { this._animationDuration = val; }
|
|
39
42
|
public set direction(val: AutoPlayOptions["direction"]) { this._direction = val; }
|
|
40
43
|
public set stopOnHover(val: boolean) { this._stopOnHover = val; }
|
|
44
|
+
public set stopOnInit(val: boolean) { this._stopOnInit = val; }
|
|
41
45
|
public set delayAfterHover(val: number) { this._delayAfterHover = val; }
|
|
42
46
|
|
|
43
47
|
/**
|
|
@@ -46,6 +50,7 @@ class AutoPlay implements Plugin {
|
|
|
46
50
|
* @param {number | undefined} options.animationDuration Duration of animation of moving to the next panel. If undefined, duration option of the Flicking instance is used instead.<ko>패널이 움직이는 애니메이션의 지속 시간, undefined라면 Flicking 인스턴스의 duration 값을 사용한다</ko>
|
|
47
51
|
* @param {"PREV" | "NEXT"} options.direction The direction in which the panel moves.<ko>패널이 움직이는 방향</ko>
|
|
48
52
|
* @param {boolean} options.stopOnHover Whether to stop when mouse hover upon the element.<ko>엘리먼트에 마우스를 올렸을 때 AutoPlay를 정지할지 여부</ko>
|
|
53
|
+
* @param {boolean} options.stopOnInit Whether to stop when mouse hover upon the element.<ko>엘리먼트에 마우스를 올렸을 때 AutoPlay를 정지할지 여부</ko>
|
|
49
54
|
* @param {number} options.delayAfterHover If stopOnHover is true, the amount of time to wait before moving on to the next panel when mouse leaves the element.<ko>stopOnHover를 사용한다면 마우스가 엘리먼트로부터 나간 뒤 다음 패널로 움직이기까지 대기 시간</ko>
|
|
50
55
|
* @example
|
|
51
56
|
* ```ts
|
|
@@ -57,12 +62,14 @@ class AutoPlay implements Plugin {
|
|
|
57
62
|
animationDuration = undefined,
|
|
58
63
|
direction = DIRECTION.NEXT,
|
|
59
64
|
stopOnHover = false,
|
|
65
|
+
stopOnInit = false,
|
|
60
66
|
delayAfterHover
|
|
61
67
|
}: Partial<AutoPlayOptions> = {}) {
|
|
62
68
|
this._duration = duration;
|
|
63
69
|
this._animationDuration = animationDuration;
|
|
64
70
|
this._direction = direction;
|
|
65
71
|
this._stopOnHover = stopOnHover;
|
|
72
|
+
this._stopOnInit = stopOnInit;
|
|
66
73
|
this._delayAfterHover = delayAfterHover ?? duration;
|
|
67
74
|
}
|
|
68
75
|
|
|
@@ -85,7 +92,9 @@ class AutoPlay implements Plugin {
|
|
|
85
92
|
targetEl.addEventListener("mouseleave", this._onMouseLeave, false);
|
|
86
93
|
}
|
|
87
94
|
|
|
88
|
-
this.
|
|
95
|
+
if (!this._stopOnInit) {
|
|
96
|
+
this.play();
|
|
97
|
+
}
|
|
89
98
|
}
|
|
90
99
|
|
|
91
100
|
public destroy(): void {
|