@egjs/flicking-plugins 4.8.0-beta.1 → 4.8.0
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/README.md +42 -51
- package/css/all.css +2 -0
- package/css/arrow.css +2 -2
- package/css/pagination.css +5 -3
- package/declaration/Arrow.d.ts +106 -51
- package/declaration/AutoPlay.d.ts +104 -44
- package/declaration/Fade.d.ts +41 -16
- package/declaration/Parallax.d.ts +41 -16
- package/declaration/Perspective.d.ts +71 -28
- package/declaration/Sync.d.ts +93 -37
- package/declaration/const.d.ts +31 -31
- package/declaration/event.d.ts +5 -5
- package/declaration/index.d.ts +13 -10
- package/declaration/pagination/Pagination.d.ts +141 -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/tsdoc-metadata.json +11 -0
- package/declaration/type.d.ts +9 -9
- package/declaration/utils.d.ts +3 -3
- package/dist/arrow.css +2 -2
- package/dist/flicking-plugins.css +23 -8
- package/dist/flicking-plugins.min.css +1 -1
- package/dist/pagination.css +21 -6
- package/dist/pagination.min.css +1 -1
- package/dist/plugins.esm.js +1029 -1591
- package/dist/plugins.esm.js.map +1 -1
- package/dist/plugins.js +1046 -1620
- package/dist/plugins.js.map +1 -1
- package/dist/plugins.min.js +1 -9
- package/dist/plugins.min.js.map +1 -1
- package/package.json +49 -105
- package/src/Arrow.ts +133 -82
- package/src/AutoPlay.ts +105 -35
- package/src/Fade.ts +31 -11
- package/src/Parallax.ts +31 -11
- package/src/Perspective.ts +69 -22
- package/src/Sync.ts +69 -25
- package/src/index.ts +9 -22
- package/src/pagination/Pagination.ts +163 -40
- package/src/pagination/index.ts +2 -6
- package/src/pagination/renderer/BulletRenderer.ts +1 -4
- package/src/pagination/renderer/FractionRenderer.ts +1 -3
- package/src/pagination/renderer/Renderer.ts +14 -13
- package/src/pagination/renderer/ScrollBulletRenderer.ts +5 -12
- package/CONTRIBUTING +0 -58
- package/rollup.config.dev.js +0 -17
- package/rollup.config.js +0 -33
- package/tsconfig.declaration.json +0 -10
- package/tsconfig.eslint.json +0 -8
- package/tsconfig.json +0 -17
- package/tsconfig.test.json +0 -21
package/dist/plugins.esm.js
CHANGED
|
@@ -1,499 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
name: @egjs/flicking-plugins
|
|
4
|
-
license: MIT
|
|
5
|
-
author: NAVER Corp.
|
|
6
|
-
repository: https://github.com/naver/egjs-flicking-plugins
|
|
7
|
-
version: 4.8.0-beta.1
|
|
8
|
-
*/
|
|
9
|
-
import { EVENTS, MOVE_TYPE, DIRECTION, FlickingError, clamp } from '@egjs/flicking';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* You can apply parallax effect while panel is moving.
|
|
13
|
-
* @ko 패널들을 움직이면서 parallax 효과를 부여할 수 있습니다.
|
|
14
|
-
* @memberof Flicking.Plugins
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
var Parallax =
|
|
18
|
-
/*#__PURE__*/
|
|
19
|
-
function () {
|
|
20
|
-
/**
|
|
21
|
-
* @param {string} selector Selector of the element to apply parallax effect<ko> Parallax 효과를 적용할 엘리먼트의 선택자 </ko>
|
|
22
|
-
* @param {number} scale Effect amplication scale<ko>효과 증폭도</ko>
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* flicking.addPlugins(new Parallax("img", 1));
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
function Parallax(selector, scale) {
|
|
29
|
-
var _this = this;
|
|
30
|
-
|
|
31
|
-
if (selector === void 0) {
|
|
32
|
-
selector = "";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (scale === void 0) {
|
|
36
|
-
scale = 1;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
this.update = function () {
|
|
40
|
-
_this._onMove();
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
this._onMove = function () {
|
|
44
|
-
var flicking = _this._flicking;
|
|
45
|
-
if (!flicking) return;
|
|
46
|
-
var panels = flicking.visiblePanels;
|
|
47
|
-
panels.forEach(function (panel) {
|
|
48
|
-
var progress = panel.outsetProgress;
|
|
49
|
-
var el = panel.element;
|
|
50
|
-
var target = _this._selector ? el.querySelector(_this._selector) : el;
|
|
51
|
-
var parentTarget = target.parentNode;
|
|
52
|
-
var rect = target.getBoundingClientRect();
|
|
53
|
-
var parentRect = parentTarget.getBoundingClientRect();
|
|
54
|
-
var position = (parentRect.width - rect.width) / 2 * progress * _this._scale;
|
|
55
|
-
var transform = "translate(-50%) translate(" + position + "px)";
|
|
56
|
-
var style = target.style;
|
|
57
|
-
style.cssText += "transform: " + transform + ";-webkit-transform: " + transform + ";-ms-transform:" + transform;
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
this._flicking = null;
|
|
62
|
-
this._selector = selector;
|
|
63
|
-
this._scale = scale;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
var __proto = Parallax.prototype;
|
|
67
|
-
Object.defineProperty(__proto, "selector", {
|
|
68
|
-
get: function () {
|
|
69
|
-
return this._selector;
|
|
70
|
-
},
|
|
71
|
-
set: function (val) {
|
|
72
|
-
this._selector = val;
|
|
73
|
-
},
|
|
74
|
-
enumerable: false,
|
|
75
|
-
configurable: true
|
|
76
|
-
});
|
|
77
|
-
Object.defineProperty(__proto, "scale", {
|
|
78
|
-
get: function () {
|
|
79
|
-
return this._scale;
|
|
80
|
-
},
|
|
81
|
-
set: function (val) {
|
|
82
|
-
this._scale = val;
|
|
83
|
-
},
|
|
84
|
-
enumerable: false,
|
|
85
|
-
configurable: true
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
__proto.init = function (flicking) {
|
|
89
|
-
if (this._flicking) {
|
|
90
|
-
this.destroy();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
this._flicking = flicking;
|
|
94
|
-
flicking.on(EVENTS.MOVE, this._onMove);
|
|
95
|
-
flicking.on(EVENTS.AFTER_RESIZE, this.update);
|
|
96
|
-
|
|
97
|
-
this._onMove();
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
__proto.destroy = function () {
|
|
101
|
-
if (!this._flicking) return;
|
|
102
|
-
|
|
103
|
-
this._flicking.off(EVENTS.MOVE, this._onMove);
|
|
104
|
-
|
|
105
|
-
this._flicking.off(EVENTS.AFTER_RESIZE, this.update);
|
|
106
|
-
|
|
107
|
-
this._flicking = null;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
return Parallax;
|
|
111
|
-
}();
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* You can apply fade in / out effect while panel is moving.
|
|
115
|
-
* @ko 패널들을 움직이면서 fade in / out 효과를 부여할 수 있습니다.
|
|
116
|
-
* @memberof Flicking.Plugins
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
var Fade =
|
|
120
|
-
/*#__PURE__*/
|
|
121
|
-
function () {
|
|
122
|
-
/**
|
|
123
|
-
* @param - The selector of the element to which the fade effect is to be applied. If the selector is blank, it applies to panel element. <ko>Fade 효과를 적용할 대상의 선택자. 선택자가 공백이면 패널 엘리먼트에 적용된다.</ko>
|
|
124
|
-
* @param - Effect amplication scale<ko>효과 증폭도</ko>
|
|
125
|
-
* @example
|
|
126
|
-
* ```ts
|
|
127
|
-
* flicking.addPlugins(new Fade("p", 1));
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
function Fade(selector, scale) {
|
|
131
|
-
var _this = this;
|
|
132
|
-
|
|
133
|
-
if (selector === void 0) {
|
|
134
|
-
selector = "";
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (scale === void 0) {
|
|
138
|
-
scale = 1;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this.update = function () {
|
|
142
|
-
_this._onMove();
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
this._onMove = function () {
|
|
146
|
-
var flicking = _this._flicking;
|
|
147
|
-
var selector = _this._selector;
|
|
148
|
-
var scale = _this._scale;
|
|
149
|
-
if (!flicking) return;
|
|
150
|
-
var panels = flicking.visiblePanels;
|
|
151
|
-
panels.forEach(function (panel) {
|
|
152
|
-
var progress = panel.outsetProgress;
|
|
153
|
-
var el = panel.element;
|
|
154
|
-
var target = selector ? el.querySelector(selector) : el;
|
|
155
|
-
|
|
156
|
-
if (target) {
|
|
157
|
-
var opacity = Math.min(1, Math.max(0, 1 - Math.abs(progress * scale)));
|
|
158
|
-
target.style.opacity = "" + opacity;
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
this._flicking = null;
|
|
164
|
-
this._selector = selector;
|
|
165
|
-
this._scale = scale;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
var __proto = Fade.prototype;
|
|
169
|
-
Object.defineProperty(__proto, "selector", {
|
|
170
|
-
get: function () {
|
|
171
|
-
return this._selector;
|
|
172
|
-
},
|
|
173
|
-
set: function (val) {
|
|
174
|
-
this._selector = val;
|
|
175
|
-
},
|
|
176
|
-
enumerable: false,
|
|
177
|
-
configurable: true
|
|
178
|
-
});
|
|
179
|
-
Object.defineProperty(__proto, "scale", {
|
|
180
|
-
get: function () {
|
|
181
|
-
return this._scale;
|
|
182
|
-
},
|
|
183
|
-
set: function (val) {
|
|
184
|
-
this._scale = val;
|
|
185
|
-
},
|
|
186
|
-
enumerable: false,
|
|
187
|
-
configurable: true
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
__proto.init = function (flicking) {
|
|
191
|
-
if (this._flicking) {
|
|
192
|
-
this.destroy();
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
this._flicking = flicking;
|
|
196
|
-
flicking.on(EVENTS.MOVE, this._onMove);
|
|
197
|
-
flicking.on(EVENTS.AFTER_RESIZE, this.update);
|
|
198
|
-
|
|
199
|
-
this._onMove();
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
__proto.destroy = function () {
|
|
203
|
-
if (!this._flicking) return;
|
|
204
|
-
|
|
205
|
-
this._flicking.off(EVENTS.MOVE, this._onMove);
|
|
206
|
-
|
|
207
|
-
this._flicking.off(EVENTS.AFTER_RESIZE, this.update);
|
|
208
|
-
|
|
209
|
-
this._flicking = null;
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
return Fade;
|
|
213
|
-
}();
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Plugin that allow you to automatically move to the next/previous panel, on a specific time basis
|
|
217
|
-
* @ko 일정 시간마다, 자동으로 다음/이전 패널로 넘어가도록 할 수 있는 플러그인
|
|
218
|
-
* @memberof Flicking.Plugins
|
|
219
|
-
*/
|
|
220
|
-
|
|
221
|
-
var AutoPlay =
|
|
222
|
-
/*#__PURE__*/
|
|
223
|
-
function () {
|
|
224
|
-
/**
|
|
225
|
-
* @param {AutoPlayOptions} options Options for the AutoPlay instance.<ko>AutoPlay 옵션</ko>
|
|
226
|
-
* @param {number} options.duration Time to wait before moving on to the next panel.<ko>다음 패널로 움직이기까지 대기 시간</ko>
|
|
227
|
-
* @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>
|
|
228
|
-
* @param {"PREV" | "NEXT"} options.direction The direction in which the panel moves.<ko>패널이 움직이는 방향</ko>
|
|
229
|
-
* @param {boolean} options.stopOnHover Whether to stop when mouse hover upon the element.<ko>엘리먼트에 마우스를 올렸을 때 AutoPlay를 정지할지 여부</ko>
|
|
230
|
-
* @param {boolean} options.stopOnInit Whether to stop when mouse hover upon the element.<ko>엘리먼트에 마우스를 올렸을 때 AutoPlay를 정지할지 여부</ko>
|
|
231
|
-
* @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>
|
|
232
|
-
* @example
|
|
233
|
-
* ```ts
|
|
234
|
-
* flicking.addPlugins(new AutoPlay({ duration: 2000, direction: "NEXT" }));
|
|
235
|
-
* ```
|
|
236
|
-
*/
|
|
237
|
-
function AutoPlay(_a) {
|
|
238
|
-
var _this = this;
|
|
239
|
-
|
|
240
|
-
var _b = _a === void 0 ? {} : _a,
|
|
241
|
-
_c = _b.duration,
|
|
242
|
-
duration = _c === void 0 ? 2000 : _c,
|
|
243
|
-
_d = _b.animationDuration,
|
|
244
|
-
animationDuration = _d === void 0 ? undefined : _d,
|
|
245
|
-
_e = _b.direction,
|
|
246
|
-
direction = _e === void 0 ? DIRECTION.NEXT : _e,
|
|
247
|
-
_f = _b.stopOnHover,
|
|
248
|
-
stopOnHover = _f === void 0 ? false : _f,
|
|
249
|
-
_g = _b.stopOnInit,
|
|
250
|
-
stopOnInit = _g === void 0 ? false : _g,
|
|
251
|
-
delayAfterHover = _b.delayAfterHover;
|
|
252
|
-
/* Internal Values */
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
this._flicking = null;
|
|
256
|
-
this._timerId = 0;
|
|
257
|
-
this._mouseEntered = false;
|
|
258
|
-
this._playing = false;
|
|
259
|
-
|
|
260
|
-
this.play = function () {
|
|
261
|
-
_this._movePanel(_this._duration);
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
this.stop = function () {
|
|
265
|
-
_this._playing = false;
|
|
266
|
-
clearTimeout(_this._timerId);
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
this._onMouseEnter = function () {
|
|
270
|
-
_this._mouseEntered = true;
|
|
271
|
-
|
|
272
|
-
_this.stop();
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
this._onMouseLeave = function () {
|
|
276
|
-
_this._mouseEntered = false;
|
|
277
|
-
|
|
278
|
-
_this._movePanel(_this._delayAfterHover);
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
this._duration = duration;
|
|
282
|
-
this._animationDuration = animationDuration;
|
|
283
|
-
this._direction = direction;
|
|
284
|
-
this._stopOnHover = stopOnHover;
|
|
285
|
-
this._stopOnInit = stopOnInit;
|
|
286
|
-
this._delayAfterHover = delayAfterHover !== null && delayAfterHover !== void 0 ? delayAfterHover : duration;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
var __proto = AutoPlay.prototype;
|
|
290
|
-
Object.defineProperty(__proto, "duration", {
|
|
291
|
-
get: function () {
|
|
292
|
-
return this._duration;
|
|
293
|
-
},
|
|
294
|
-
set: function (val) {
|
|
295
|
-
this._duration = val;
|
|
296
|
-
},
|
|
297
|
-
enumerable: false,
|
|
298
|
-
configurable: true
|
|
299
|
-
});
|
|
300
|
-
Object.defineProperty(__proto, "animationDuration", {
|
|
301
|
-
get: function () {
|
|
302
|
-
return this._animationDuration;
|
|
303
|
-
},
|
|
304
|
-
set: function (val) {
|
|
305
|
-
this._animationDuration = val;
|
|
306
|
-
},
|
|
307
|
-
enumerable: false,
|
|
308
|
-
configurable: true
|
|
309
|
-
});
|
|
310
|
-
Object.defineProperty(__proto, "direction", {
|
|
311
|
-
get: function () {
|
|
312
|
-
return this._direction;
|
|
313
|
-
},
|
|
314
|
-
set: function (val) {
|
|
315
|
-
this._direction = val;
|
|
316
|
-
},
|
|
317
|
-
enumerable: false,
|
|
318
|
-
configurable: true
|
|
319
|
-
});
|
|
320
|
-
Object.defineProperty(__proto, "stopOnHover", {
|
|
321
|
-
get: function () {
|
|
322
|
-
return this._stopOnHover;
|
|
323
|
-
},
|
|
324
|
-
set: function (val) {
|
|
325
|
-
this._stopOnHover = val;
|
|
326
|
-
},
|
|
327
|
-
enumerable: false,
|
|
328
|
-
configurable: true
|
|
329
|
-
});
|
|
330
|
-
Object.defineProperty(__proto, "stopOnInit", {
|
|
331
|
-
get: function () {
|
|
332
|
-
return this._stopOnInit;
|
|
333
|
-
},
|
|
334
|
-
set: function (val) {
|
|
335
|
-
this._stopOnInit = val;
|
|
336
|
-
},
|
|
337
|
-
enumerable: false,
|
|
338
|
-
configurable: true
|
|
339
|
-
});
|
|
340
|
-
Object.defineProperty(__proto, "delayAfterHover", {
|
|
341
|
-
get: function () {
|
|
342
|
-
return this._delayAfterHover;
|
|
343
|
-
},
|
|
344
|
-
set: function (val) {
|
|
345
|
-
this._delayAfterHover = val;
|
|
346
|
-
},
|
|
347
|
-
enumerable: false,
|
|
348
|
-
configurable: true
|
|
349
|
-
});
|
|
350
|
-
Object.defineProperty(__proto, "playing", {
|
|
351
|
-
get: function () {
|
|
352
|
-
return this._playing;
|
|
353
|
-
},
|
|
354
|
-
enumerable: false,
|
|
355
|
-
configurable: true
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
__proto.init = function (flicking) {
|
|
359
|
-
var _a;
|
|
360
|
-
|
|
361
|
-
if (this._flicking) {
|
|
362
|
-
this.destroy();
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
flicking.on((_a = {}, _a[EVENTS.MOVE_START] = this.stop, _a[EVENTS.HOLD_START] = this.stop, _a[EVENTS.MOVE_END] = this.play, _a[EVENTS.SELECT] = this.play, _a));
|
|
366
|
-
this._flicking = flicking;
|
|
367
|
-
|
|
368
|
-
if (this._stopOnHover) {
|
|
369
|
-
var targetEl = this._flicking.element;
|
|
370
|
-
targetEl.addEventListener("mouseenter", this._onMouseEnter, false);
|
|
371
|
-
targetEl.addEventListener("mouseleave", this._onMouseLeave, false);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (!this._stopOnInit) {
|
|
375
|
-
this.play();
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
__proto.destroy = function () {
|
|
380
|
-
var flicking = this._flicking;
|
|
381
|
-
this._mouseEntered = false;
|
|
382
|
-
this.stop();
|
|
383
|
-
|
|
384
|
-
if (!flicking) {
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
flicking.off(EVENTS.MOVE_START, this.stop);
|
|
389
|
-
flicking.off(EVENTS.HOLD_START, this.stop);
|
|
390
|
-
flicking.off(EVENTS.MOVE_END, this.play);
|
|
391
|
-
flicking.off(EVENTS.SELECT, this.play);
|
|
392
|
-
var targetEl = flicking.element;
|
|
393
|
-
targetEl.removeEventListener("mouseenter", this._onMouseEnter, false);
|
|
394
|
-
targetEl.removeEventListener("mouseleave", this._onMouseLeave, false);
|
|
395
|
-
this._flicking = null;
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
__proto.update = function () {// DO-NOTHING
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
__proto._movePanel = function (duration) {
|
|
402
|
-
var _this = this;
|
|
403
|
-
|
|
404
|
-
var flicking = this._flicking;
|
|
405
|
-
var direction = this._direction;
|
|
406
|
-
|
|
407
|
-
if (!flicking) {
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
this.stop();
|
|
412
|
-
|
|
413
|
-
if (this._mouseEntered || flicking.animating) {
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
this._playing = true;
|
|
418
|
-
this._timerId = window.setTimeout(function () {
|
|
419
|
-
var _a, _b;
|
|
420
|
-
|
|
421
|
-
var animationDuration = _this._animationDuration || flicking.duration;
|
|
422
|
-
var moveType = flicking.moveType; // for freeScroll
|
|
423
|
-
|
|
424
|
-
if (moveType === MOVE_TYPE.FREE_SCROLL || (moveType === null || moveType === void 0 ? void 0 : moveType[0]) === MOVE_TYPE.FREE_SCROLL) {
|
|
425
|
-
var range = flicking.camera.range;
|
|
426
|
-
var cameraPosition = flicking.camera.position;
|
|
427
|
-
var currentPanel = flicking.currentPanel;
|
|
428
|
-
var prevPanel = currentPanel.prev();
|
|
429
|
-
var nextPanel = currentPanel.next();
|
|
430
|
-
var currentPosition = currentPanel.position;
|
|
431
|
-
var nextPosition = (_a = nextPanel === null || nextPanel === void 0 ? void 0 : nextPanel.position) !== null && _a !== void 0 ? _a : range.max;
|
|
432
|
-
var prevPosition = (_b = prevPanel === null || prevPanel === void 0 ? void 0 : prevPanel.position) !== null && _b !== void 0 ? _b : range.min; // circular: prev (last) > cur (0) => prev(-1) < cur(0)
|
|
433
|
-
|
|
434
|
-
if (prevPosition > currentPosition) {
|
|
435
|
-
prevPosition = range.min - (range.max - prevPosition);
|
|
436
|
-
} // current (last) > next (0)
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
if (nextPosition < currentPosition) {
|
|
440
|
-
nextPosition += range.max;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
if (direction === DIRECTION.NEXT) {
|
|
444
|
-
// prev - cur - camera - next
|
|
445
|
-
var size = nextPosition - currentPosition;
|
|
446
|
-
var restSize = nextPosition - cameraPosition;
|
|
447
|
-
|
|
448
|
-
if (cameraPosition < currentPosition) {
|
|
449
|
-
// prev - camera - cur - next
|
|
450
|
-
restSize = nextPosition - cameraPosition;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
animationDuration *= restSize / size;
|
|
454
|
-
} else {
|
|
455
|
-
// prev - caemra - cur - next
|
|
456
|
-
var size = currentPosition - prevPosition;
|
|
457
|
-
var restSize = cameraPosition - prevPosition;
|
|
458
|
-
|
|
459
|
-
if (cameraPosition > currentPosition) {
|
|
460
|
-
// prev - cur - camera - next
|
|
461
|
-
restSize = cameraPosition - prevPosition;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
animationDuration *= restSize / size;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
if (direction === DIRECTION.NEXT) {
|
|
469
|
-
flicking.next(animationDuration).catch(function () {
|
|
470
|
-
return void 0;
|
|
471
|
-
});
|
|
472
|
-
} else {
|
|
473
|
-
flicking.prev(animationDuration).catch(function () {
|
|
474
|
-
return void 0;
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
_this.play();
|
|
479
|
-
}, duration);
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
return AutoPlay;
|
|
483
|
-
}();
|
|
484
|
-
|
|
485
|
-
var BROWSER = {
|
|
486
|
-
CLICK: "click",
|
|
487
|
-
MOUSE_DOWN: "mousedown",
|
|
488
|
-
TOUCH_START: "touchstart"
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
var ARROW = {
|
|
1
|
+
import { FlickingError, EVENTS, DIRECTION, MOVE_TYPE, clamp } from "@egjs/flicking";
|
|
2
|
+
const ARROW = {
|
|
492
3
|
PREV_SELECTOR: ".flicking-arrow-prev",
|
|
493
4
|
NEXT_SELECTOR: ".flicking-arrow-next",
|
|
494
5
|
DISABLED_CLASS: "flicking-arrow-disabled"
|
|
495
6
|
};
|
|
496
|
-
|
|
7
|
+
const PAGINATION = {
|
|
497
8
|
SELECTOR: ".flicking-pagination",
|
|
498
9
|
PREFIX: "flicking-pagination",
|
|
499
10
|
BULLET_WRAPPER_SUFFIX: "bullets",
|
|
@@ -513,437 +24,752 @@ var PAGINATION = {
|
|
|
513
24
|
SCROLL: "scroll"
|
|
514
25
|
}
|
|
515
26
|
};
|
|
516
|
-
|
|
27
|
+
const SYNC = {
|
|
517
28
|
TYPE: {
|
|
518
29
|
CAMERA: "camera",
|
|
519
30
|
INDEX: "index"
|
|
520
31
|
}
|
|
521
32
|
};
|
|
522
|
-
|
|
523
|
-
|
|
33
|
+
const BROWSER = {
|
|
34
|
+
CLICK: "click",
|
|
35
|
+
MOUSE_DOWN: "mousedown",
|
|
36
|
+
TOUCH_START: "touchstart"
|
|
37
|
+
};
|
|
38
|
+
const addClass = (el, className) => {
|
|
524
39
|
if (!el) return;
|
|
525
|
-
|
|
526
40
|
if (el.classList) {
|
|
527
41
|
el.classList.add(className);
|
|
528
42
|
} else {
|
|
529
|
-
|
|
530
|
-
|
|
43
|
+
const classes = el.className.split(" ");
|
|
531
44
|
if (classes.indexOf(className) < 0) {
|
|
532
|
-
el.className = el.className
|
|
45
|
+
el.className = `${el.className} ${className}`;
|
|
533
46
|
}
|
|
534
47
|
}
|
|
535
48
|
};
|
|
536
|
-
|
|
49
|
+
const removeClass = (el, className) => {
|
|
537
50
|
if (!el) return;
|
|
538
|
-
|
|
539
51
|
if (el.classList) {
|
|
540
52
|
el.classList.remove(className);
|
|
541
53
|
} else {
|
|
542
|
-
|
|
54
|
+
const classRegex = new RegExp(`( |^)${className}( |$)`, "g");
|
|
543
55
|
el.className.replace(classRegex, " ");
|
|
544
56
|
}
|
|
545
57
|
};
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
58
|
+
const getElement = (selector, parent, pluginName) => {
|
|
59
|
+
const el = parent.querySelector(selector);
|
|
549
60
|
if (!el) {
|
|
550
|
-
throw new Error(
|
|
61
|
+
throw new Error(`[Flicking-${pluginName}] Couldn't find element with the given selector: ${selector}`);
|
|
551
62
|
}
|
|
552
|
-
|
|
553
63
|
return el;
|
|
554
64
|
};
|
|
555
|
-
|
|
556
|
-
/**
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
function () {
|
|
565
|
-
function Arrow(_a) {
|
|
566
|
-
var _this = this;
|
|
567
|
-
|
|
568
|
-
var _b = _a === void 0 ? {} : _a,
|
|
569
|
-
_c = _b.parentEl,
|
|
570
|
-
parentEl = _c === void 0 ? null : _c,
|
|
571
|
-
_d = _b.prevElSelector,
|
|
572
|
-
prevElSelector = _d === void 0 ? ARROW.PREV_SELECTOR : _d,
|
|
573
|
-
_e = _b.nextElSelector,
|
|
574
|
-
nextElSelector = _e === void 0 ? ARROW.NEXT_SELECTOR : _e,
|
|
575
|
-
_f = _b.disabledClass,
|
|
576
|
-
disabledClass = _f === void 0 ? ARROW.DISABLED_CLASS : _f,
|
|
577
|
-
_g = _b.moveCount,
|
|
578
|
-
moveCount = _g === void 0 ? 1 : _g,
|
|
579
|
-
_h = _b.moveByViewportSize,
|
|
580
|
-
moveByViewportSize = _h === void 0 ? false : _h,
|
|
581
|
-
_j = _b.interruptable,
|
|
582
|
-
interruptable = _j === void 0 ? false : _j;
|
|
583
|
-
/* Internal Values */
|
|
584
|
-
|
|
585
|
-
|
|
65
|
+
class Arrow {
|
|
66
|
+
/**
|
|
67
|
+
* @param options - Options for the Arrow instance
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* flicking.addPlugins(new Arrow({ parentEl: null, prevElSelector: ".flicking-arrow-prev", nextElSelector: ".flicking-arrow-next" }));
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
constructor(options = {}) {
|
|
586
74
|
this._flicking = null;
|
|
587
|
-
|
|
588
|
-
this._preventInputPropagation = function (e) {
|
|
75
|
+
this._preventInputPropagation = (e) => {
|
|
589
76
|
e.stopPropagation();
|
|
590
77
|
};
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
if (
|
|
599
|
-
|
|
600
|
-
if (flicking.animating) {
|
|
601
|
-
flicking.stopAnimation();
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
var firstAnchor = anchorPoints[0];
|
|
605
|
-
var moveCount = _this._moveCount;
|
|
606
|
-
|
|
607
|
-
if (_this._moveByViewportSize) {
|
|
608
|
-
flicking.control.moveToPosition(camera.position - camera.size, flicking.duration).catch(_this._onCatch);
|
|
78
|
+
this._onPrevClick = () => {
|
|
79
|
+
const flicking = this._flicking;
|
|
80
|
+
const camera = flicking.camera;
|
|
81
|
+
const anchorPoints = camera.anchorPoints;
|
|
82
|
+
if (flicking.animating || anchorPoints.length <= 0) return;
|
|
83
|
+
const firstAnchor = anchorPoints[0];
|
|
84
|
+
const moveCount2 = this._moveCount;
|
|
85
|
+
if (this._moveByViewportSize) {
|
|
86
|
+
flicking.control.moveToPosition(camera.position - camera.size, flicking.duration).catch(this._onCatch);
|
|
609
87
|
} else {
|
|
610
88
|
if (flicking.circularEnabled) {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
for (var i = 0; i < moveCount; i++) {
|
|
89
|
+
let targetPanel = flicking.currentPanel;
|
|
90
|
+
for (let i = 0; i < moveCount2; i++) {
|
|
614
91
|
targetPanel = targetPanel.prev();
|
|
615
92
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
flicking.moveTo(Math.max(index - moveCount, firstAnchor.panel.index)).catch(_this._onCatch);
|
|
93
|
+
targetPanel.focus().catch(this._onCatch);
|
|
94
|
+
} else if (flicking.index > firstAnchor.panel.index) {
|
|
95
|
+
flicking.moveTo(Math.max(flicking.index - moveCount2, firstAnchor.panel.index)).catch(this._onCatch);
|
|
620
96
|
} else if (camera.position > camera.range.min) {
|
|
621
|
-
flicking.moveTo(index).catch(
|
|
97
|
+
flicking.moveTo(flicking.index).catch(this._onCatch);
|
|
622
98
|
}
|
|
623
99
|
}
|
|
624
100
|
};
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
if (
|
|
633
|
-
|
|
634
|
-
if (flicking.animating) {
|
|
635
|
-
flicking.stopAnimation();
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
var lastAnchor = anchorPoints[anchorPoints.length - 1];
|
|
639
|
-
var moveCount = _this._moveCount;
|
|
640
|
-
|
|
641
|
-
if (_this._moveByViewportSize) {
|
|
642
|
-
flicking.control.moveToPosition(camera.position + camera.size, flicking.duration).catch(_this._onCatch);
|
|
101
|
+
this._onNextClick = () => {
|
|
102
|
+
const flicking = this._flicking;
|
|
103
|
+
const camera = flicking.camera;
|
|
104
|
+
const anchorPoints = camera.anchorPoints;
|
|
105
|
+
if (flicking.animating || anchorPoints.length <= 0) return;
|
|
106
|
+
const lastAnchor = anchorPoints[anchorPoints.length - 1];
|
|
107
|
+
const moveCount2 = this._moveCount;
|
|
108
|
+
if (this._moveByViewportSize) {
|
|
109
|
+
flicking.control.moveToPosition(camera.position + camera.size, flicking.duration).catch(this._onCatch);
|
|
643
110
|
} else {
|
|
644
111
|
if (flicking.circularEnabled) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
for (var i = 0; i < moveCount; i++) {
|
|
112
|
+
let targetPanel = flicking.currentPanel;
|
|
113
|
+
for (let i = 0; i < moveCount2; i++) {
|
|
648
114
|
targetPanel = targetPanel.next();
|
|
649
115
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
flicking.moveTo(Math.min(index + moveCount, lastAnchor.panel.index)).catch(_this._onCatch);
|
|
116
|
+
targetPanel.focus().catch(this._onCatch);
|
|
117
|
+
} else if (flicking.index < lastAnchor.panel.index) {
|
|
118
|
+
flicking.moveTo(Math.min(flicking.index + moveCount2, lastAnchor.panel.index)).catch(this._onCatch);
|
|
654
119
|
} else if (camera.position > camera.range.min) {
|
|
655
|
-
flicking.moveTo(index).catch(
|
|
120
|
+
flicking.moveTo(flicking.index).catch(this._onCatch);
|
|
656
121
|
}
|
|
657
122
|
}
|
|
658
123
|
};
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
var controller = flicking.control.controller;
|
|
664
|
-
|
|
124
|
+
this._onAnimation = () => {
|
|
125
|
+
const flicking = this._flicking;
|
|
126
|
+
const camera = flicking.camera;
|
|
127
|
+
const controller = flicking.control.controller;
|
|
665
128
|
if (flicking.holding) {
|
|
666
|
-
|
|
129
|
+
this._updateClass(camera.position);
|
|
667
130
|
} else {
|
|
668
|
-
|
|
131
|
+
this._updateClass(controller.animatingContext.end);
|
|
669
132
|
}
|
|
670
133
|
};
|
|
671
|
-
|
|
672
|
-
this._onWillChange = function (e) {
|
|
673
|
-
_this._nextIndex = e.index;
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
this._onCatch = function (err) {
|
|
134
|
+
this._onCatch = (err) => {
|
|
677
135
|
if (err instanceof FlickingError) return;
|
|
678
136
|
throw err;
|
|
679
137
|
};
|
|
680
|
-
|
|
138
|
+
const {
|
|
139
|
+
parentEl = null,
|
|
140
|
+
prevElSelector = ARROW.PREV_SELECTOR,
|
|
141
|
+
nextElSelector = ARROW.NEXT_SELECTOR,
|
|
142
|
+
disabledClass = ARROW.DISABLED_CLASS,
|
|
143
|
+
moveCount = 1,
|
|
144
|
+
moveByViewportSize = false
|
|
145
|
+
} = options;
|
|
681
146
|
this._parentEl = parentEl;
|
|
682
147
|
this._prevElSelector = prevElSelector;
|
|
683
148
|
this._nextElSelector = nextElSelector;
|
|
684
149
|
this._disabledClass = disabledClass;
|
|
685
150
|
this._moveCount = moveCount;
|
|
686
151
|
this._moveByViewportSize = moveByViewportSize;
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
enumerable: false,
|
|
753
|
-
configurable: true
|
|
754
|
-
});
|
|
755
|
-
Object.defineProperty(__proto, "moveByViewportSize", {
|
|
756
|
-
get: function () {
|
|
757
|
-
return this._moveByViewportSize;
|
|
758
|
-
},
|
|
759
|
-
set: function (val) {
|
|
760
|
-
this._moveByViewportSize = val;
|
|
761
|
-
},
|
|
762
|
-
enumerable: false,
|
|
763
|
-
configurable: true
|
|
764
|
-
});
|
|
765
|
-
Object.defineProperty(__proto, "interruptable", {
|
|
766
|
-
get: function () {
|
|
767
|
-
return this._interruptable;
|
|
768
|
-
},
|
|
769
|
-
set: function (val) {
|
|
770
|
-
this._interruptable = val;
|
|
771
|
-
},
|
|
772
|
-
enumerable: false,
|
|
773
|
-
configurable: true
|
|
774
|
-
});
|
|
775
|
-
|
|
776
|
-
__proto.init = function (flicking) {
|
|
777
|
-
var _this = this;
|
|
778
|
-
|
|
152
|
+
}
|
|
153
|
+
/** The "previous" arrow HTMLElement
|
|
154
|
+
* @readonly
|
|
155
|
+
*/
|
|
156
|
+
get prevEl() {
|
|
157
|
+
return this._prevEl;
|
|
158
|
+
}
|
|
159
|
+
/** The "next" arrow HTMLElement
|
|
160
|
+
* @readonly
|
|
161
|
+
*/
|
|
162
|
+
get nextEl() {
|
|
163
|
+
return this._nextEl;
|
|
164
|
+
}
|
|
165
|
+
/** Current value of the {@link ArrowOptions.parentEl | parentEl} option. */
|
|
166
|
+
get parentEl() {
|
|
167
|
+
return this._parentEl;
|
|
168
|
+
}
|
|
169
|
+
/** Current value of the {@link ArrowOptions.prevElSelector | prevElSelector} option. */
|
|
170
|
+
get prevElSelector() {
|
|
171
|
+
return this._prevElSelector;
|
|
172
|
+
}
|
|
173
|
+
/** Current value of the {@link ArrowOptions.nextElSelector | nextElSelector} option. */
|
|
174
|
+
get nextElSelector() {
|
|
175
|
+
return this._nextElSelector;
|
|
176
|
+
}
|
|
177
|
+
/** Current value of the {@link ArrowOptions.disabledClass | disabledClass} option. */
|
|
178
|
+
get disabledClass() {
|
|
179
|
+
return this._disabledClass;
|
|
180
|
+
}
|
|
181
|
+
/** Current value of the {@link ArrowOptions.moveCount | moveCount} option. */
|
|
182
|
+
get moveCount() {
|
|
183
|
+
return this._moveCount;
|
|
184
|
+
}
|
|
185
|
+
/** Current value of the {@link ArrowOptions.moveByViewportSize | moveByViewportSize} option. */
|
|
186
|
+
get moveByViewportSize() {
|
|
187
|
+
return this._moveByViewportSize;
|
|
188
|
+
}
|
|
189
|
+
/** Sets {@link ArrowOptions.parentEl | parentEl}. */
|
|
190
|
+
set parentEl(val) {
|
|
191
|
+
this._parentEl = val;
|
|
192
|
+
}
|
|
193
|
+
/** Sets {@link ArrowOptions.prevElSelector | prevElSelector}. */
|
|
194
|
+
set prevElSelector(val) {
|
|
195
|
+
this._prevElSelector = val;
|
|
196
|
+
}
|
|
197
|
+
/** Sets {@link ArrowOptions.nextElSelector | nextElSelector}. */
|
|
198
|
+
set nextElSelector(val) {
|
|
199
|
+
this._nextElSelector = val;
|
|
200
|
+
}
|
|
201
|
+
/** Sets {@link ArrowOptions.disabledClass | disabledClass}. */
|
|
202
|
+
set disabledClass(val) {
|
|
203
|
+
this._disabledClass = val;
|
|
204
|
+
}
|
|
205
|
+
/** Sets {@link ArrowOptions.moveCount | moveCount}. */
|
|
206
|
+
set moveCount(val) {
|
|
207
|
+
this._moveCount = val;
|
|
208
|
+
}
|
|
209
|
+
/** Sets {@link ArrowOptions.moveByViewportSize | moveByViewportSize}. */
|
|
210
|
+
set moveByViewportSize(val) {
|
|
211
|
+
this._moveByViewportSize = val;
|
|
212
|
+
}
|
|
213
|
+
/** Initialize the plugin and attach arrow event listeners to the Flicking instance.
|
|
214
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
215
|
+
*/
|
|
216
|
+
init(flicking) {
|
|
779
217
|
if (this._flicking) {
|
|
780
218
|
this.destroy();
|
|
781
219
|
}
|
|
782
|
-
|
|
783
220
|
this._flicking = flicking;
|
|
784
221
|
flicking.on(EVENTS.MOVE, this._onAnimation);
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
passive: true
|
|
792
|
-
});
|
|
793
|
-
nextEl.addEventListener(evt, _this._preventInputPropagation, {
|
|
794
|
-
passive: true
|
|
795
|
-
});
|
|
222
|
+
const parentEl = this._parentEl ? this._parentEl : flicking.element;
|
|
223
|
+
const prevEl = getElement(this._prevElSelector, parentEl, "Arrow");
|
|
224
|
+
const nextEl = getElement(this._nextElSelector, parentEl, "Arrow");
|
|
225
|
+
[BROWSER.MOUSE_DOWN, BROWSER.TOUCH_START].forEach((evt) => {
|
|
226
|
+
prevEl.addEventListener(evt, this._preventInputPropagation, { passive: true });
|
|
227
|
+
nextEl.addEventListener(evt, this._preventInputPropagation, { passive: true });
|
|
796
228
|
});
|
|
797
229
|
prevEl.addEventListener(BROWSER.CLICK, this._onPrevClick);
|
|
798
230
|
nextEl.addEventListener(BROWSER.CLICK, this._onNextClick);
|
|
799
231
|
this._prevEl = prevEl;
|
|
800
232
|
this._nextEl = nextEl;
|
|
801
233
|
this.update();
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
var flicking = this._flicking;
|
|
808
|
-
|
|
234
|
+
}
|
|
235
|
+
/** Destroy the plugin and remove all arrow event listeners. */
|
|
236
|
+
destroy() {
|
|
237
|
+
const flicking = this._flicking;
|
|
809
238
|
if (!flicking) {
|
|
810
239
|
return;
|
|
811
240
|
}
|
|
812
|
-
|
|
813
241
|
flicking.off(EVENTS.MOVE, this._onAnimation);
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
nextEl.removeEventListener(evt, _this._preventInputPropagation);
|
|
242
|
+
const prevEl = this._prevEl;
|
|
243
|
+
const nextEl = this._nextEl;
|
|
244
|
+
[BROWSER.MOUSE_DOWN, BROWSER.TOUCH_START].forEach((evt) => {
|
|
245
|
+
prevEl.removeEventListener(evt, this._preventInputPropagation);
|
|
246
|
+
nextEl.removeEventListener(evt, this._preventInputPropagation);
|
|
820
247
|
});
|
|
821
248
|
prevEl.removeEventListener(BROWSER.CLICK, this._onPrevClick);
|
|
822
249
|
nextEl.removeEventListener(BROWSER.CLICK, this._onNextClick);
|
|
823
250
|
this._flicking = null;
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
|
|
251
|
+
}
|
|
252
|
+
/** Update the arrow disabled/enabled state based on the current camera position. */
|
|
253
|
+
update() {
|
|
827
254
|
this._updateClass(this._flicking.camera.position);
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
var stopAtNextEdge = flicking.circularEnabled ? false : pos >= cameraRange.max;
|
|
838
|
-
|
|
255
|
+
}
|
|
256
|
+
_updateClass(pos) {
|
|
257
|
+
const flicking = this._flicking;
|
|
258
|
+
const disabledClass = this._disabledClass;
|
|
259
|
+
const prevEl = this._prevEl;
|
|
260
|
+
const nextEl = this._nextEl;
|
|
261
|
+
const cameraRange = flicking.camera.range;
|
|
262
|
+
const stopAtPrevEdge = flicking.circularEnabled ? false : pos <= cameraRange.min;
|
|
263
|
+
const stopAtNextEdge = flicking.circularEnabled ? false : pos >= cameraRange.max;
|
|
839
264
|
if (stopAtPrevEdge) {
|
|
840
265
|
addClass(prevEl, disabledClass);
|
|
841
266
|
} else {
|
|
842
267
|
removeClass(prevEl, disabledClass);
|
|
843
268
|
}
|
|
844
|
-
|
|
845
269
|
if (stopAtNextEdge) {
|
|
846
270
|
addClass(nextEl, disabledClass);
|
|
847
271
|
} else {
|
|
848
272
|
removeClass(nextEl, disabledClass);
|
|
849
273
|
}
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
var Sync =
|
|
862
|
-
/*#__PURE__*/
|
|
863
|
-
function () {
|
|
864
|
-
/** */
|
|
865
|
-
function Sync(_a) {
|
|
866
|
-
var _this = this;
|
|
867
|
-
|
|
868
|
-
var _b = _a === void 0 ? {} : _a,
|
|
869
|
-
_c = _b.type,
|
|
870
|
-
type = _c === void 0 ? SYNC.TYPE.CAMERA : _c,
|
|
871
|
-
_d = _b.synchronizedFlickingOptions,
|
|
872
|
-
synchronizedFlickingOptions = _d === void 0 ? [] : _d;
|
|
873
|
-
/* Internal Values */
|
|
874
|
-
|
|
875
|
-
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
class AutoPlay {
|
|
277
|
+
/**
|
|
278
|
+
* @param options - Options for the AutoPlay instance
|
|
279
|
+
* @example
|
|
280
|
+
* ```ts
|
|
281
|
+
* flicking.addPlugins(new AutoPlay({ duration: 2000, direction: "NEXT" }));
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
constructor(options = {}) {
|
|
876
285
|
this._flicking = null;
|
|
877
|
-
|
|
878
|
-
this.
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
286
|
+
this._timerId = 0;
|
|
287
|
+
this._mouseEntered = false;
|
|
288
|
+
this._playing = false;
|
|
289
|
+
this.play = () => {
|
|
290
|
+
this._movePanel(this._duration);
|
|
291
|
+
};
|
|
292
|
+
this.stop = () => {
|
|
293
|
+
this._playing = false;
|
|
294
|
+
clearTimeout(this._timerId);
|
|
295
|
+
};
|
|
296
|
+
this._onMouseEnter = () => {
|
|
297
|
+
this._mouseEntered = true;
|
|
298
|
+
this.stop();
|
|
299
|
+
};
|
|
300
|
+
this._onMouseLeave = () => {
|
|
301
|
+
this._mouseEntered = false;
|
|
302
|
+
this._movePanel(this._delayAfterHover);
|
|
303
|
+
};
|
|
304
|
+
const {
|
|
305
|
+
duration = 2e3,
|
|
306
|
+
animationDuration = void 0,
|
|
307
|
+
direction = DIRECTION.NEXT,
|
|
308
|
+
stopOnHover = false,
|
|
309
|
+
stopOnInit = false,
|
|
310
|
+
delayAfterHover
|
|
311
|
+
} = options;
|
|
312
|
+
this._duration = duration;
|
|
313
|
+
this._animationDuration = animationDuration;
|
|
314
|
+
this._direction = direction;
|
|
315
|
+
this._stopOnHover = stopOnHover;
|
|
316
|
+
this._stopOnInit = stopOnInit;
|
|
317
|
+
this._delayAfterHover = delayAfterHover ?? duration;
|
|
318
|
+
}
|
|
319
|
+
/** Current value of the {@link AutoPlayOptions.duration | duration} option. */
|
|
320
|
+
get duration() {
|
|
321
|
+
return this._duration;
|
|
322
|
+
}
|
|
323
|
+
/** Current value of the {@link AutoPlayOptions.animationDuration | animationDuration} option. */
|
|
324
|
+
get animationDuration() {
|
|
325
|
+
return this._animationDuration;
|
|
326
|
+
}
|
|
327
|
+
/** Current value of the {@link AutoPlayOptions.direction | direction} option. */
|
|
328
|
+
get direction() {
|
|
329
|
+
return this._direction;
|
|
330
|
+
}
|
|
331
|
+
/** Current value of the {@link AutoPlayOptions.stopOnHover | stopOnHover} option. */
|
|
332
|
+
get stopOnHover() {
|
|
333
|
+
return this._stopOnHover;
|
|
334
|
+
}
|
|
335
|
+
/** Current value of the {@link AutoPlayOptions.stopOnInit | stopOnInit} option. */
|
|
336
|
+
get stopOnInit() {
|
|
337
|
+
return this._stopOnInit;
|
|
338
|
+
}
|
|
339
|
+
/** Current value of the {@link AutoPlayOptions.delayAfterHover | delayAfterHover} option. */
|
|
340
|
+
get delayAfterHover() {
|
|
341
|
+
return this._delayAfterHover;
|
|
342
|
+
}
|
|
343
|
+
/** Whether the autoplay is currently active
|
|
344
|
+
* @readonly
|
|
345
|
+
*/
|
|
346
|
+
get playing() {
|
|
347
|
+
return this._playing;
|
|
348
|
+
}
|
|
349
|
+
/** Sets {@link AutoPlayOptions.duration | duration}. */
|
|
350
|
+
set duration(val) {
|
|
351
|
+
this._duration = val;
|
|
352
|
+
}
|
|
353
|
+
/** Sets {@link AutoPlayOptions.animationDuration | animationDuration}. */
|
|
354
|
+
set animationDuration(val) {
|
|
355
|
+
this._animationDuration = val;
|
|
356
|
+
}
|
|
357
|
+
/** Sets {@link AutoPlayOptions.direction | direction}. */
|
|
358
|
+
set direction(val) {
|
|
359
|
+
this._direction = val;
|
|
360
|
+
}
|
|
361
|
+
/** Sets {@link AutoPlayOptions.stopOnHover | stopOnHover}. */
|
|
362
|
+
set stopOnHover(val) {
|
|
363
|
+
this._stopOnHover = val;
|
|
364
|
+
}
|
|
365
|
+
/** Sets {@link AutoPlayOptions.stopOnInit | stopOnInit}. */
|
|
366
|
+
set stopOnInit(val) {
|
|
367
|
+
this._stopOnInit = val;
|
|
368
|
+
}
|
|
369
|
+
/** Sets {@link AutoPlayOptions.delayAfterHover | delayAfterHover}. */
|
|
370
|
+
set delayAfterHover(val) {
|
|
371
|
+
this._delayAfterHover = val;
|
|
372
|
+
}
|
|
373
|
+
/** Initialize the plugin and start autoplay on the given Flicking instance.
|
|
374
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
375
|
+
*/
|
|
376
|
+
init(flicking) {
|
|
377
|
+
if (this._flicking) {
|
|
378
|
+
this.destroy();
|
|
379
|
+
}
|
|
380
|
+
flicking.on({
|
|
381
|
+
[EVENTS.MOVE_START]: this.stop,
|
|
382
|
+
[EVENTS.HOLD_START]: this.stop,
|
|
383
|
+
[EVENTS.MOVE_END]: this.play,
|
|
384
|
+
[EVENTS.SELECT]: this.play
|
|
385
|
+
});
|
|
386
|
+
this._flicking = flicking;
|
|
387
|
+
if (this._stopOnHover) {
|
|
388
|
+
const targetEl = this._flicking.element;
|
|
389
|
+
targetEl.addEventListener("mouseenter", this._onMouseEnter, false);
|
|
390
|
+
targetEl.addEventListener("mouseleave", this._onMouseLeave, false);
|
|
391
|
+
}
|
|
392
|
+
if (!this._stopOnInit) {
|
|
393
|
+
this.play();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
/** Destroy the plugin, stop autoplay, and remove all event listeners. */
|
|
397
|
+
destroy() {
|
|
398
|
+
const flicking = this._flicking;
|
|
399
|
+
this._mouseEntered = false;
|
|
400
|
+
this.stop();
|
|
401
|
+
if (!flicking) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
flicking.off(EVENTS.MOVE_START, this.stop);
|
|
405
|
+
flicking.off(EVENTS.HOLD_START, this.stop);
|
|
406
|
+
flicking.off(EVENTS.MOVE_END, this.play);
|
|
407
|
+
flicking.off(EVENTS.SELECT, this.play);
|
|
408
|
+
const targetEl = flicking.element;
|
|
409
|
+
targetEl.removeEventListener("mouseenter", this._onMouseEnter, false);
|
|
410
|
+
targetEl.removeEventListener("mouseleave", this._onMouseLeave, false);
|
|
411
|
+
this._flicking = null;
|
|
412
|
+
}
|
|
413
|
+
/** Update the plugin state. This is a no-op for AutoPlay. */
|
|
414
|
+
update() {
|
|
415
|
+
}
|
|
416
|
+
_movePanel(duration) {
|
|
417
|
+
const flicking = this._flicking;
|
|
418
|
+
const direction = this._direction;
|
|
419
|
+
if (!flicking) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
this.stop();
|
|
423
|
+
if (this._mouseEntered || flicking.animating) {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
this._playing = true;
|
|
427
|
+
this._timerId = window.setTimeout(() => {
|
|
428
|
+
let animationDuration = this._animationDuration || flicking.duration;
|
|
429
|
+
const moveType = flicking.moveType;
|
|
430
|
+
if (moveType === MOVE_TYPE.FREE_SCROLL || moveType?.[0] === MOVE_TYPE.FREE_SCROLL) {
|
|
431
|
+
const range = flicking.camera.range;
|
|
432
|
+
const cameraPosition = flicking.camera.position;
|
|
433
|
+
const currentPanel = flicking.currentPanel;
|
|
434
|
+
const prevPanel = currentPanel.prev();
|
|
435
|
+
const nextPanel = currentPanel.next();
|
|
436
|
+
const currentPosition = currentPanel.position;
|
|
437
|
+
let nextPosition = nextPanel?.position ?? range.max;
|
|
438
|
+
let prevPosition = prevPanel?.position ?? range.min;
|
|
439
|
+
if (prevPosition > currentPosition) {
|
|
440
|
+
prevPosition = range.min - (range.max - prevPosition);
|
|
890
441
|
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
442
|
+
if (nextPosition < currentPosition) {
|
|
443
|
+
nextPosition += range.max;
|
|
444
|
+
}
|
|
445
|
+
if (direction === DIRECTION.NEXT) {
|
|
446
|
+
const size = nextPosition - currentPosition;
|
|
447
|
+
let restSize = nextPosition - cameraPosition;
|
|
448
|
+
if (cameraPosition < currentPosition) {
|
|
449
|
+
restSize = nextPosition - cameraPosition;
|
|
450
|
+
}
|
|
451
|
+
animationDuration *= restSize / size;
|
|
452
|
+
} else {
|
|
453
|
+
const size = currentPosition - prevPosition;
|
|
454
|
+
let restSize = cameraPosition - prevPosition;
|
|
455
|
+
if (cameraPosition > currentPosition) {
|
|
456
|
+
restSize = cameraPosition - prevPosition;
|
|
457
|
+
}
|
|
458
|
+
animationDuration *= restSize / size;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (direction === DIRECTION.NEXT) {
|
|
462
|
+
flicking.next(animationDuration).catch(() => void 0);
|
|
463
|
+
} else {
|
|
464
|
+
flicking.prev(animationDuration).catch(() => void 0);
|
|
465
|
+
}
|
|
466
|
+
this.play();
|
|
467
|
+
}, duration);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
class Fade {
|
|
471
|
+
/**
|
|
472
|
+
* @param selector - CSS selector for the element to apply the fade effect. If empty, the panel element itself is used
|
|
473
|
+
* @param scale - Effect amplification scale
|
|
474
|
+
* @example
|
|
475
|
+
* ```ts
|
|
476
|
+
* flicking.addPlugins(new Fade("p", 1));
|
|
477
|
+
* ```
|
|
478
|
+
*/
|
|
479
|
+
constructor(selector = "", scale = 1) {
|
|
480
|
+
this.update = () => {
|
|
481
|
+
this._onMove();
|
|
482
|
+
};
|
|
483
|
+
this._onMove = () => {
|
|
484
|
+
const flicking = this._flicking;
|
|
485
|
+
const selector2 = this._selector;
|
|
486
|
+
const scale2 = this._scale;
|
|
487
|
+
if (!flicking) return;
|
|
488
|
+
const panels = flicking.visiblePanels;
|
|
489
|
+
panels.forEach((panel) => {
|
|
490
|
+
const progress = panel.outsetProgress;
|
|
491
|
+
const el = panel.element;
|
|
492
|
+
const target = selector2 ? el.querySelector(selector2) : el;
|
|
493
|
+
if (target) {
|
|
494
|
+
const opacity = Math.min(1, Math.max(0, 1 - Math.abs(progress * scale2)));
|
|
495
|
+
target.style.opacity = `${opacity}`;
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
};
|
|
499
|
+
this._flicking = null;
|
|
500
|
+
this._selector = selector;
|
|
501
|
+
this._scale = scale;
|
|
502
|
+
}
|
|
503
|
+
/** CSS selector for the element to apply the fade effect. If empty, the panel element itself is used
|
|
504
|
+
* @readonly
|
|
505
|
+
*/
|
|
506
|
+
get selector() {
|
|
507
|
+
return this._selector;
|
|
508
|
+
}
|
|
509
|
+
/** Effect amplification scale
|
|
510
|
+
* @readonly
|
|
511
|
+
*/
|
|
512
|
+
get scale() {
|
|
513
|
+
return this._scale;
|
|
514
|
+
}
|
|
515
|
+
/** Sets the CSS selector for the target fade element. */
|
|
516
|
+
set selector(val) {
|
|
517
|
+
this._selector = val;
|
|
518
|
+
}
|
|
519
|
+
/** Sets the effect amplification scale. */
|
|
520
|
+
set scale(val) {
|
|
521
|
+
this._scale = val;
|
|
522
|
+
}
|
|
523
|
+
/** Initialize the plugin and apply the fade effect to the Flicking instance.
|
|
524
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
525
|
+
*/
|
|
526
|
+
init(flicking) {
|
|
527
|
+
if (this._flicking) {
|
|
528
|
+
this.destroy();
|
|
529
|
+
}
|
|
530
|
+
this._flicking = flicking;
|
|
531
|
+
flicking.on(EVENTS.MOVE, this._onMove);
|
|
532
|
+
flicking.on(EVENTS.AFTER_RESIZE, this.update);
|
|
533
|
+
this._onMove();
|
|
534
|
+
}
|
|
535
|
+
/** Destroy the plugin and remove all event listeners. */
|
|
536
|
+
destroy() {
|
|
537
|
+
if (!this._flicking) return;
|
|
538
|
+
this._flicking.off(EVENTS.MOVE, this._onMove);
|
|
539
|
+
this._flicking.off(EVENTS.AFTER_RESIZE, this.update);
|
|
540
|
+
this._flicking = null;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
class Parallax {
|
|
544
|
+
/**
|
|
545
|
+
* @param selector - CSS selector for the element to apply the parallax effect. If empty, the panel element itself is used
|
|
546
|
+
* @param scale - Effect amplification scale
|
|
547
|
+
* @example
|
|
548
|
+
* ```ts
|
|
549
|
+
* flicking.addPlugins(new Parallax("img", 1));
|
|
550
|
+
* ```
|
|
551
|
+
*/
|
|
552
|
+
constructor(selector = "", scale = 1) {
|
|
553
|
+
this.update = () => {
|
|
554
|
+
this._onMove();
|
|
555
|
+
};
|
|
556
|
+
this._onMove = () => {
|
|
557
|
+
const flicking = this._flicking;
|
|
558
|
+
if (!flicking) return;
|
|
559
|
+
const panels = flicking.visiblePanels;
|
|
560
|
+
panels.forEach((panel) => {
|
|
561
|
+
const progress = panel.outsetProgress;
|
|
562
|
+
const el = panel.element;
|
|
563
|
+
const target = this._selector ? el.querySelector(this._selector) : el;
|
|
564
|
+
const parentTarget = target.parentNode;
|
|
565
|
+
const rect = target.getBoundingClientRect();
|
|
566
|
+
const parentRect = parentTarget.getBoundingClientRect();
|
|
567
|
+
const position = (parentRect.width - rect.width) / 2 * progress * this._scale;
|
|
568
|
+
const transform = `translate(-50%) translate(${position}px)`;
|
|
569
|
+
const style = target.style;
|
|
570
|
+
style.cssText += `transform: ${transform};-webkit-transform: ${transform};-ms-transform:${transform}`;
|
|
571
|
+
});
|
|
572
|
+
};
|
|
573
|
+
this._flicking = null;
|
|
574
|
+
this._selector = selector;
|
|
575
|
+
this._scale = scale;
|
|
576
|
+
}
|
|
577
|
+
/** CSS selector for the element to apply the parallax effect. If empty, the panel element itself is used
|
|
578
|
+
* @readonly
|
|
579
|
+
*/
|
|
580
|
+
get selector() {
|
|
581
|
+
return this._selector;
|
|
582
|
+
}
|
|
583
|
+
/** Effect amplification scale
|
|
584
|
+
* @readonly
|
|
585
|
+
*/
|
|
586
|
+
get scale() {
|
|
587
|
+
return this._scale;
|
|
588
|
+
}
|
|
589
|
+
/** Sets the CSS selector for the target parallax element. */
|
|
590
|
+
set selector(val) {
|
|
591
|
+
this._selector = val;
|
|
592
|
+
}
|
|
593
|
+
/** Sets the effect amplification scale. */
|
|
594
|
+
set scale(val) {
|
|
595
|
+
this._scale = val;
|
|
596
|
+
}
|
|
597
|
+
/** Initialize the plugin and apply the parallax effect to the Flicking instance.
|
|
598
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
599
|
+
*/
|
|
600
|
+
init(flicking) {
|
|
601
|
+
if (this._flicking) {
|
|
602
|
+
this.destroy();
|
|
603
|
+
}
|
|
604
|
+
this._flicking = flicking;
|
|
605
|
+
flicking.on(EVENTS.MOVE, this._onMove);
|
|
606
|
+
flicking.on(EVENTS.AFTER_RESIZE, this.update);
|
|
607
|
+
this._onMove();
|
|
608
|
+
}
|
|
609
|
+
/** Destroy the plugin and remove all event listeners. */
|
|
610
|
+
destroy() {
|
|
611
|
+
if (!this._flicking) return;
|
|
612
|
+
this._flicking.off(EVENTS.MOVE, this._onMove);
|
|
613
|
+
this._flicking.off(EVENTS.AFTER_RESIZE, this.update);
|
|
614
|
+
this._flicking = null;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
class Perspective {
|
|
618
|
+
/**
|
|
619
|
+
* @param options - Options for the Perspective instance
|
|
620
|
+
* @example
|
|
621
|
+
* ```ts
|
|
622
|
+
* flicking.addPlugins(new Perspective({ selector: "p", scale: 1, rotate: 1, perspective: 1000 }));
|
|
623
|
+
* ```
|
|
624
|
+
*/
|
|
625
|
+
constructor(options = {}) {
|
|
626
|
+
this.update = () => {
|
|
627
|
+
this._onMove();
|
|
628
|
+
};
|
|
629
|
+
this._onMove = () => {
|
|
630
|
+
const flicking = this._flicking;
|
|
631
|
+
const selector2 = this._selector;
|
|
632
|
+
const scale2 = this._scale;
|
|
633
|
+
const rotate2 = this._rotate;
|
|
634
|
+
const perspective2 = this._perspective;
|
|
635
|
+
if (!flicking) return;
|
|
636
|
+
const horizontal = flicking.horizontal;
|
|
637
|
+
const panels = flicking.visiblePanels;
|
|
638
|
+
panels.forEach((panel) => {
|
|
639
|
+
const progress = panel.outsetProgress;
|
|
640
|
+
const el = panel.element;
|
|
641
|
+
const target = selector2 ? el.querySelector(selector2) : el;
|
|
642
|
+
const panelScale = 1 / (Math.abs(progress * scale2) + 1);
|
|
643
|
+
const rotateDegree = progress > 0 ? Math.min(90, progress * 100 * rotate2) : Math.max(-90, progress * 100 * rotate2);
|
|
644
|
+
const [rotateX, rotateY] = horizontal ? [0, rotateDegree] : [rotateDegree, 0];
|
|
645
|
+
target.style.transform = `perspective(${perspective2}px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(${panelScale})`;
|
|
646
|
+
});
|
|
647
|
+
};
|
|
648
|
+
const { selector = "", scale = 1, rotate = 1, perspective = 1e3 } = options;
|
|
649
|
+
this._flicking = null;
|
|
650
|
+
this._selector = selector;
|
|
651
|
+
this._scale = scale;
|
|
652
|
+
this._rotate = rotate;
|
|
653
|
+
this._perspective = perspective;
|
|
654
|
+
}
|
|
655
|
+
/** Current value of the {@link PerspectiveOptions.selector | selector} option. */
|
|
656
|
+
get selector() {
|
|
657
|
+
return this._selector;
|
|
658
|
+
}
|
|
659
|
+
/** Current value of the {@link PerspectiveOptions.scale | scale} option. */
|
|
660
|
+
get scale() {
|
|
661
|
+
return this._scale;
|
|
662
|
+
}
|
|
663
|
+
/** Current value of the {@link PerspectiveOptions.rotate | rotate} option. */
|
|
664
|
+
get rotate() {
|
|
665
|
+
return this._rotate;
|
|
666
|
+
}
|
|
667
|
+
/** Current value of the {@link PerspectiveOptions.perspective | perspective} option. */
|
|
668
|
+
get perspective() {
|
|
669
|
+
return this._perspective;
|
|
670
|
+
}
|
|
671
|
+
/** Sets {@link PerspectiveOptions.selector | selector}. */
|
|
672
|
+
set selector(val) {
|
|
673
|
+
this._selector = val;
|
|
674
|
+
}
|
|
675
|
+
/** Sets {@link PerspectiveOptions.scale | scale}. */
|
|
676
|
+
set scale(val) {
|
|
677
|
+
this._scale = val;
|
|
678
|
+
}
|
|
679
|
+
/** Sets {@link PerspectiveOptions.rotate | rotate}. */
|
|
680
|
+
set rotate(val) {
|
|
681
|
+
this._rotate = val;
|
|
682
|
+
}
|
|
683
|
+
/** Sets {@link PerspectiveOptions.perspective | perspective}. */
|
|
684
|
+
set perspective(val) {
|
|
685
|
+
this._perspective = val;
|
|
686
|
+
}
|
|
687
|
+
/** Initialize the plugin and apply the perspective effect to the Flicking instance.
|
|
688
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
689
|
+
*/
|
|
690
|
+
init(flicking) {
|
|
691
|
+
if (this._flicking) {
|
|
692
|
+
this.destroy();
|
|
693
|
+
}
|
|
694
|
+
this._flicking = flicking;
|
|
695
|
+
flicking.on(EVENTS.MOVE, this._onMove);
|
|
696
|
+
flicking.on(EVENTS.AFTER_RESIZE, this.update);
|
|
697
|
+
this._onMove();
|
|
698
|
+
}
|
|
699
|
+
/** Destroy the plugin and remove all event listeners. */
|
|
700
|
+
destroy() {
|
|
701
|
+
if (!this._flicking) return;
|
|
702
|
+
this._flicking.off(EVENTS.MOVE, this._onMove);
|
|
703
|
+
this._flicking.off(EVENTS.AFTER_RESIZE, this.update);
|
|
704
|
+
this._flicking = null;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
class Sync {
|
|
708
|
+
/**
|
|
709
|
+
* @param options - Options for the Sync instance
|
|
710
|
+
* @example
|
|
711
|
+
* ```ts
|
|
712
|
+
* flicking.addPlugins(new Sync({
|
|
713
|
+
* type: "camera",
|
|
714
|
+
* synchronizedFlickingOptions: [
|
|
715
|
+
* { flicking: flicking1 },
|
|
716
|
+
* { flicking: flicking2, isClickable: true }
|
|
717
|
+
* ]
|
|
718
|
+
* }));
|
|
719
|
+
* ```
|
|
720
|
+
*/
|
|
721
|
+
constructor(options = {}) {
|
|
722
|
+
this._flicking = null;
|
|
723
|
+
this._disabledIndex = [];
|
|
724
|
+
this._addEvents = () => {
|
|
725
|
+
const type2 = this._type;
|
|
726
|
+
const synced = this._synchronizedFlickingOptions;
|
|
727
|
+
synced.forEach(({ flicking, isSlidable, isClickable }) => {
|
|
728
|
+
if (type2 === SYNC.TYPE.CAMERA) {
|
|
729
|
+
flicking.on(EVENTS.MOVE, this._onMove);
|
|
730
|
+
flicking.on(EVENTS.MOVE_START, this._onMoveStart);
|
|
731
|
+
flicking.on(EVENTS.MOVE_END, this._onMoveEnd);
|
|
732
|
+
}
|
|
733
|
+
if (type2 === SYNC.TYPE.INDEX && isSlidable) {
|
|
734
|
+
flicking.on(EVENTS.WILL_CHANGE, this._onIndexChange);
|
|
735
|
+
flicking.on(EVENTS.WILL_RESTORE, this._onIndexChange);
|
|
895
736
|
}
|
|
896
|
-
|
|
897
737
|
if (isClickable) {
|
|
898
|
-
flicking.on(EVENTS.SELECT,
|
|
738
|
+
flicking.on(EVENTS.SELECT, this._onSelect);
|
|
899
739
|
}
|
|
900
740
|
});
|
|
901
741
|
};
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
if (type === SYNC.TYPE.CAMERA) {
|
|
912
|
-
flicking.off(EVENTS.MOVE, _this._onMove);
|
|
913
|
-
flicking.off(EVENTS.MOVE_START, _this._onMoveStart);
|
|
914
|
-
flicking.off(EVENTS.MOVE_END, _this._onMoveEnd);
|
|
742
|
+
this._removeEvents = () => {
|
|
743
|
+
const type2 = this._type;
|
|
744
|
+
const synced = this._synchronizedFlickingOptions;
|
|
745
|
+
synced.forEach(({ flicking, isSlidable, isClickable }) => {
|
|
746
|
+
if (type2 === SYNC.TYPE.CAMERA) {
|
|
747
|
+
flicking.off(EVENTS.MOVE, this._onMove);
|
|
748
|
+
flicking.off(EVENTS.MOVE_START, this._onMoveStart);
|
|
749
|
+
flicking.off(EVENTS.MOVE_END, this._onMoveEnd);
|
|
915
750
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
flicking.off(EVENTS.
|
|
919
|
-
flicking.off(EVENTS.WILL_RESTORE, _this._onIndexChange);
|
|
751
|
+
if (type2 === SYNC.TYPE.INDEX && isSlidable) {
|
|
752
|
+
flicking.off(EVENTS.WILL_CHANGE, this._onIndexChange);
|
|
753
|
+
flicking.off(EVENTS.WILL_RESTORE, this._onIndexChange);
|
|
920
754
|
}
|
|
921
|
-
|
|
922
755
|
if (isClickable) {
|
|
923
|
-
flicking.off(EVENTS.SELECT,
|
|
756
|
+
flicking.off(EVENTS.SELECT, this._onSelect);
|
|
924
757
|
}
|
|
925
758
|
});
|
|
926
759
|
};
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
var flicking = e.currentTarget;
|
|
930
|
-
|
|
760
|
+
this._onIndexChange = (e) => {
|
|
761
|
+
const flicking = e.currentTarget;
|
|
931
762
|
if (!flicking.initialized) {
|
|
932
763
|
return;
|
|
933
764
|
}
|
|
934
|
-
|
|
935
|
-
_this._synchronizeByIndex(flicking, e.index);
|
|
765
|
+
this._synchronizeByIndex(flicking, e.index);
|
|
936
766
|
};
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
_this._synchronizedFlickingOptions.forEach(function (_a) {
|
|
943
|
-
var flicking = _a.flicking;
|
|
767
|
+
this._onMove = (e) => {
|
|
768
|
+
const camera = e.currentTarget.camera;
|
|
769
|
+
const progress = (camera.position - camera.range.min) / camera.rangeDiff;
|
|
770
|
+
this._synchronizedFlickingOptions.forEach(({ flicking }) => {
|
|
944
771
|
if (flicking === e.currentTarget) return;
|
|
945
|
-
|
|
946
|
-
|
|
772
|
+
let targetPosition = 0;
|
|
947
773
|
if (camera.position < camera.range.min) {
|
|
948
774
|
targetPosition = camera.position;
|
|
949
775
|
} else if (camera.position > camera.range.max) {
|
|
@@ -951,58 +777,40 @@ function () {
|
|
|
951
777
|
} else {
|
|
952
778
|
targetPosition = flicking.camera.range.min + flicking.camera.rangeDiff * progress;
|
|
953
779
|
}
|
|
954
|
-
|
|
955
780
|
void flicking.camera.lookAt(targetPosition);
|
|
956
781
|
});
|
|
957
782
|
};
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
if (flicking !== e.currentTarget) {
|
|
783
|
+
this._onMoveStart = (e) => {
|
|
784
|
+
this._disabledIndex = [];
|
|
785
|
+
this._synchronizedFlickingOptions.forEach(({ flicking }, i) => {
|
|
786
|
+
if (flicking !== e.currentTarget && flicking.control.controller.enabled) {
|
|
787
|
+
this._disabledIndex.push(i);
|
|
964
788
|
flicking.disableInput();
|
|
965
789
|
}
|
|
966
790
|
});
|
|
967
791
|
};
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
if (flicking !== e.currentTarget) {
|
|
974
|
-
flicking.enableInput();
|
|
975
|
-
flicking.control.updateInput();
|
|
976
|
-
}
|
|
792
|
+
this._onMoveEnd = (e) => {
|
|
793
|
+
this._disabledIndex.forEach((i) => {
|
|
794
|
+
const flicking = this._synchronizedFlickingOptions[i].flicking;
|
|
795
|
+
flicking.enableInput();
|
|
796
|
+
flicking.control.updateInput();
|
|
977
797
|
});
|
|
978
798
|
};
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
return void 0;
|
|
983
|
-
});
|
|
984
|
-
|
|
985
|
-
_this._synchronizeByIndex(e.currentTarget, e.index);
|
|
799
|
+
this._onSelect = (e) => {
|
|
800
|
+
void e.currentTarget.moveTo(e.index).catch(() => void 0);
|
|
801
|
+
this._synchronizeByIndex(e.currentTarget, e.index);
|
|
986
802
|
};
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
// Active class should be applied same to the Flicking which triggered event
|
|
994
|
-
_this._updateClass(options, index);
|
|
995
|
-
|
|
996
|
-
var flicking = options.flicking;
|
|
803
|
+
this._synchronizeByIndex = (activeFlicking, index) => {
|
|
804
|
+
const synchronizedFlickingOptions2 = this._synchronizedFlickingOptions;
|
|
805
|
+
this._preventEvent(() => {
|
|
806
|
+
synchronizedFlickingOptions2.forEach((options2) => {
|
|
807
|
+
this._updateClass(options2, index);
|
|
808
|
+
const { flicking } = options2;
|
|
997
809
|
if (flicking === activeFlicking) return;
|
|
998
|
-
|
|
999
|
-
|
|
810
|
+
const targetIndex = clamp(index, 0, flicking.panels.length);
|
|
1000
811
|
if (flicking.animating) {
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
void flicking.moveTo(targetIndex).catch(function () {
|
|
1004
|
-
return void 0;
|
|
1005
|
-
});
|
|
812
|
+
flicking.once(EVENTS.MOVE_END, () => {
|
|
813
|
+
void flicking.moveTo(targetIndex).catch(() => void 0);
|
|
1006
814
|
});
|
|
1007
815
|
} else {
|
|
1008
816
|
void flicking.moveTo(targetIndex);
|
|
@@ -1010,12 +818,9 @@ function () {
|
|
|
1010
818
|
});
|
|
1011
819
|
});
|
|
1012
820
|
};
|
|
1013
|
-
|
|
1014
|
-
this._updateClass = function (_a, index) {
|
|
1015
|
-
var flicking = _a.flicking,
|
|
1016
|
-
activeClass = _a.activeClass;
|
|
821
|
+
this._updateClass = ({ flicking, activeClass }, index) => {
|
|
1017
822
|
if (!activeClass) return;
|
|
1018
|
-
flicking.panels.forEach(
|
|
823
|
+
flicking.panels.forEach((panel) => {
|
|
1019
824
|
if (panel.index === index) {
|
|
1020
825
|
addClass(panel.element, activeClass);
|
|
1021
826
|
} else {
|
|
@@ -1023,617 +828,318 @@ function () {
|
|
|
1023
828
|
}
|
|
1024
829
|
});
|
|
1025
830
|
};
|
|
1026
|
-
|
|
831
|
+
const { type = SYNC.TYPE.CAMERA, synchronizedFlickingOptions = [] } = options;
|
|
1027
832
|
this._type = type;
|
|
1028
833
|
this._synchronizedFlickingOptions = synchronizedFlickingOptions;
|
|
1029
834
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
});
|
|
1052
|
-
|
|
1053
|
-
__proto.init = function (flicking) {
|
|
1054
|
-
var _this = this;
|
|
1055
|
-
|
|
1056
|
-
var synced = this._synchronizedFlickingOptions;
|
|
1057
|
-
|
|
835
|
+
/** Current value of the {@link SyncOptions.type | type} option. */
|
|
836
|
+
get type() {
|
|
837
|
+
return this._type;
|
|
838
|
+
}
|
|
839
|
+
/** Current value of the {@link SyncOptions.synchronizedFlickingOptions | synchronizedFlickingOptions} option. */
|
|
840
|
+
get synchronizedFlickingOptions() {
|
|
841
|
+
return this._synchronizedFlickingOptions;
|
|
842
|
+
}
|
|
843
|
+
/** Sets {@link SyncOptions.type | type}. */
|
|
844
|
+
set type(val) {
|
|
845
|
+
this._type = val;
|
|
846
|
+
}
|
|
847
|
+
/** Sets {@link SyncOptions.synchronizedFlickingOptions | synchronizedFlickingOptions}. */
|
|
848
|
+
set synchronizedFlickingOptions(val) {
|
|
849
|
+
this._synchronizedFlickingOptions = val;
|
|
850
|
+
}
|
|
851
|
+
/** Initialize the plugin and set up synchronization event listeners between Flicking instances.
|
|
852
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
853
|
+
*/
|
|
854
|
+
init(flicking) {
|
|
855
|
+
const synced = this._synchronizedFlickingOptions;
|
|
1058
856
|
if (this._flicking) {
|
|
1059
857
|
this.destroy();
|
|
1060
858
|
}
|
|
1061
|
-
|
|
1062
859
|
this._flicking = flicking;
|
|
1063
|
-
|
|
1064
860
|
this._addEvents();
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
_this._updateClass(options, syncedFlicking.defaultIndex);
|
|
861
|
+
synced.forEach((options) => {
|
|
862
|
+
const { flicking: syncedFlicking } = options;
|
|
863
|
+
this._updateClass(options, syncedFlicking.defaultIndex);
|
|
1070
864
|
});
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
865
|
+
}
|
|
866
|
+
/** Destroy the plugin and remove all synchronization event listeners. */
|
|
867
|
+
destroy() {
|
|
868
|
+
const flicking = this._flicking;
|
|
1076
869
|
if (!flicking) {
|
|
1077
870
|
return;
|
|
1078
871
|
}
|
|
1079
|
-
|
|
1080
872
|
this._removeEvents();
|
|
1081
|
-
|
|
1082
873
|
this._flicking = null;
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
this._synchronizedFlickingOptions.forEach(function (options) {
|
|
1089
|
-
_this._updateClass(options, options.flicking.index);
|
|
874
|
+
}
|
|
875
|
+
/** Update the active class state for all synchronized Flicking instances. */
|
|
876
|
+
update() {
|
|
877
|
+
this._synchronizedFlickingOptions.forEach((options) => {
|
|
878
|
+
this._updateClass(options, options.flicking.index);
|
|
1090
879
|
});
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
__proto._preventEvent = function (fn) {
|
|
880
|
+
}
|
|
881
|
+
_preventEvent(fn) {
|
|
1094
882
|
this._removeEvents();
|
|
1095
|
-
|
|
1096
883
|
fn();
|
|
1097
|
-
|
|
1098
884
|
this._addEvents();
|
|
1099
|
-
};
|
|
1100
|
-
|
|
1101
|
-
return Sync;
|
|
1102
|
-
}();
|
|
1103
|
-
|
|
1104
|
-
/* eslint-disable no-underscore-dangle */
|
|
1105
|
-
/**
|
|
1106
|
-
* You can apply perspective effect while panel is moving.
|
|
1107
|
-
* @ko 패널들을 움직이면서 입체감을 부여할 수 있습니다.
|
|
1108
|
-
* @memberof Flicking.Plugins
|
|
1109
|
-
*/
|
|
1110
|
-
|
|
1111
|
-
var Perspective =
|
|
1112
|
-
/*#__PURE__*/
|
|
1113
|
-
function () {
|
|
1114
|
-
/**
|
|
1115
|
-
* @param - The selector of the element to which the perspective effect is to be applied. If the selector is blank, it applies to panel element. <ko>입체 효과를 적용할 대상의 선택자. 선택자가 공백이면 패널 엘리먼트에 적용된다.</ko>
|
|
1116
|
-
* @param - Effect amplication scale.<ko>효과 증폭도</ko>
|
|
1117
|
-
* @param - Effect amplication rotate.<ko>회전 증폭도</ko>
|
|
1118
|
-
* @param - The value of perspective CSS property. <ko>css perspective 속성 값</ko>
|
|
1119
|
-
* @example
|
|
1120
|
-
* ```ts
|
|
1121
|
-
* flicking.addPlugins(new Perspective({ selector: "p", scale: 1, rotate: 1, perspective = 1000 }));
|
|
1122
|
-
* ```
|
|
1123
|
-
*/
|
|
1124
|
-
function Perspective(_a) {
|
|
1125
|
-
var _this = this;
|
|
1126
|
-
|
|
1127
|
-
var _b = _a === void 0 ? {} : _a,
|
|
1128
|
-
_c = _b.selector,
|
|
1129
|
-
selector = _c === void 0 ? "" : _c,
|
|
1130
|
-
_d = _b.scale,
|
|
1131
|
-
scale = _d === void 0 ? 1 : _d,
|
|
1132
|
-
_e = _b.rotate,
|
|
1133
|
-
rotate = _e === void 0 ? 1 : _e,
|
|
1134
|
-
_f = _b.perspective,
|
|
1135
|
-
perspective = _f === void 0 ? 1000 : _f;
|
|
1136
|
-
|
|
1137
|
-
this.update = function () {
|
|
1138
|
-
_this._onMove();
|
|
1139
|
-
};
|
|
1140
|
-
|
|
1141
|
-
this._onMove = function () {
|
|
1142
|
-
var flicking = _this._flicking;
|
|
1143
|
-
var selector = _this._selector;
|
|
1144
|
-
var scale = _this._scale;
|
|
1145
|
-
var rotate = _this._rotate;
|
|
1146
|
-
var perspective = _this._perspective;
|
|
1147
|
-
if (!flicking) return;
|
|
1148
|
-
var horizontal = flicking.horizontal;
|
|
1149
|
-
var panels = flicking.visiblePanels;
|
|
1150
|
-
panels.forEach(function (panel) {
|
|
1151
|
-
var progress = panel.outsetProgress;
|
|
1152
|
-
var el = panel.element;
|
|
1153
|
-
var target = selector ? el.querySelector(selector) : el;
|
|
1154
|
-
var panelScale = 1 / (Math.abs(progress * scale) + 1);
|
|
1155
|
-
var rotateDegree = progress > 0 ? Math.min(90, progress * 100 * rotate) : Math.max(-90, progress * 100 * rotate);
|
|
1156
|
-
|
|
1157
|
-
var _a = horizontal ? [0, rotateDegree] : [rotateDegree, 0],
|
|
1158
|
-
rotateX = _a[0],
|
|
1159
|
-
rotateY = _a[1];
|
|
1160
|
-
|
|
1161
|
-
target.style.transform = "perspective(" + perspective + "px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg) scale(" + panelScale + ")";
|
|
1162
|
-
});
|
|
1163
|
-
};
|
|
1164
|
-
|
|
1165
|
-
this._flicking = null;
|
|
1166
|
-
this._selector = selector;
|
|
1167
|
-
this._scale = scale;
|
|
1168
|
-
this._rotate = rotate;
|
|
1169
|
-
this._perspective = perspective;
|
|
1170
885
|
}
|
|
1171
|
-
|
|
1172
|
-
var __proto = Perspective.prototype;
|
|
1173
|
-
Object.defineProperty(__proto, "selector", {
|
|
1174
|
-
get: function () {
|
|
1175
|
-
return this._selector;
|
|
1176
|
-
},
|
|
1177
|
-
set: function (val) {
|
|
1178
|
-
this._selector = val;
|
|
1179
|
-
},
|
|
1180
|
-
enumerable: false,
|
|
1181
|
-
configurable: true
|
|
1182
|
-
});
|
|
1183
|
-
Object.defineProperty(__proto, "scale", {
|
|
1184
|
-
get: function () {
|
|
1185
|
-
return this._scale;
|
|
1186
|
-
},
|
|
1187
|
-
set: function (val) {
|
|
1188
|
-
this._scale = val;
|
|
1189
|
-
},
|
|
1190
|
-
enumerable: false,
|
|
1191
|
-
configurable: true
|
|
1192
|
-
});
|
|
1193
|
-
Object.defineProperty(__proto, "rotate", {
|
|
1194
|
-
get: function () {
|
|
1195
|
-
return this._rotate;
|
|
1196
|
-
},
|
|
1197
|
-
set: function (val) {
|
|
1198
|
-
this._rotate = val;
|
|
1199
|
-
},
|
|
1200
|
-
enumerable: false,
|
|
1201
|
-
configurable: true
|
|
1202
|
-
});
|
|
1203
|
-
Object.defineProperty(__proto, "perspective", {
|
|
1204
|
-
get: function () {
|
|
1205
|
-
return this._perspective;
|
|
1206
|
-
},
|
|
1207
|
-
set: function (val) {
|
|
1208
|
-
this._perspective = val;
|
|
1209
|
-
},
|
|
1210
|
-
enumerable: false,
|
|
1211
|
-
configurable: true
|
|
1212
|
-
});
|
|
1213
|
-
|
|
1214
|
-
__proto.init = function (flicking) {
|
|
1215
|
-
if (this._flicking) {
|
|
1216
|
-
this.destroy();
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
this._flicking = flicking;
|
|
1220
|
-
flicking.on(EVENTS.MOVE, this._onMove);
|
|
1221
|
-
flicking.on(EVENTS.AFTER_RESIZE, this.update);
|
|
1222
|
-
|
|
1223
|
-
this._onMove();
|
|
1224
|
-
};
|
|
1225
|
-
|
|
1226
|
-
__proto.destroy = function () {
|
|
1227
|
-
if (!this._flicking) return;
|
|
1228
|
-
|
|
1229
|
-
this._flicking.off(EVENTS.MOVE, this._onMove);
|
|
1230
|
-
|
|
1231
|
-
this._flicking.off(EVENTS.AFTER_RESIZE, this.update);
|
|
1232
|
-
|
|
1233
|
-
this._flicking = null;
|
|
1234
|
-
};
|
|
1235
|
-
|
|
1236
|
-
return Perspective;
|
|
1237
|
-
}();
|
|
1238
|
-
|
|
1239
|
-
/*! *****************************************************************************
|
|
1240
|
-
Copyright (c) Microsoft Corporation.
|
|
1241
|
-
|
|
1242
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
1243
|
-
purpose with or without fee is hereby granted.
|
|
1244
|
-
|
|
1245
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1246
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1247
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1248
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1249
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1250
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1251
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
1252
|
-
***************************************************************************** */
|
|
1253
|
-
|
|
1254
|
-
/* global Reflect, Promise */
|
|
1255
|
-
var extendStatics = function (d, b) {
|
|
1256
|
-
extendStatics = Object.setPrototypeOf || {
|
|
1257
|
-
__proto__: []
|
|
1258
|
-
} instanceof Array && function (d, b) {
|
|
1259
|
-
d.__proto__ = b;
|
|
1260
|
-
} || function (d, b) {
|
|
1261
|
-
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1262
|
-
};
|
|
1263
|
-
|
|
1264
|
-
return extendStatics(d, b);
|
|
1265
|
-
};
|
|
1266
|
-
|
|
1267
|
-
function __extends(d, b) {
|
|
1268
|
-
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1269
|
-
extendStatics(d, b);
|
|
1270
|
-
|
|
1271
|
-
function __() {
|
|
1272
|
-
this.constructor = d;
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1276
886
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1281
|
-
ar[i] = from[i];
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
return to.concat(ar || from);
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
var Renderer =
|
|
1288
|
-
/*#__PURE__*/
|
|
1289
|
-
function () {
|
|
1290
|
-
function Renderer(_a) {
|
|
1291
|
-
var flicking = _a.flicking,
|
|
1292
|
-
pagination = _a.pagination,
|
|
1293
|
-
wrapper = _a.wrapper;
|
|
887
|
+
class Renderer {
|
|
888
|
+
constructor(options) {
|
|
889
|
+
const { flicking, pagination, wrapper } = options;
|
|
1294
890
|
this._flicking = flicking;
|
|
1295
891
|
this._pagination = pagination;
|
|
1296
892
|
this._wrapper = wrapper;
|
|
1297
893
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
var range = document.createRange();
|
|
1303
|
-
var frag = range.createContextualFragment(html);
|
|
1304
|
-
var bullet = frag.firstChild;
|
|
1305
|
-
|
|
894
|
+
_createBulletFromString(html, index) {
|
|
895
|
+
const range = document.createRange();
|
|
896
|
+
const frag = range.createContextualFragment(html);
|
|
897
|
+
const bullet = frag.firstChild;
|
|
1306
898
|
this._addBulletEvents(bullet, index);
|
|
1307
|
-
|
|
1308
899
|
return bullet;
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
var anchorPoints = this._flicking.camera.anchorPoints;
|
|
1315
|
-
var panelIndex = anchorPoints[index].panel.index;
|
|
1316
|
-
bullet.addEventListener(BROWSER.MOUSE_DOWN, function (e) {
|
|
1317
|
-
e.stopPropagation();
|
|
1318
|
-
});
|
|
1319
|
-
bullet.addEventListener(BROWSER.TOUCH_START, function (e) {
|
|
900
|
+
}
|
|
901
|
+
_addBulletEvents(bullet, index) {
|
|
902
|
+
const anchorPoints = this._flicking.camera.anchorPoints;
|
|
903
|
+
const panelIndex = anchorPoints[index].panel.index;
|
|
904
|
+
bullet.addEventListener(BROWSER.MOUSE_DOWN, (e) => {
|
|
1320
905
|
e.stopPropagation();
|
|
1321
|
-
}, {
|
|
1322
|
-
passive: true
|
|
1323
906
|
});
|
|
1324
|
-
bullet.addEventListener(
|
|
1325
|
-
|
|
907
|
+
bullet.addEventListener(
|
|
908
|
+
BROWSER.TOUCH_START,
|
|
909
|
+
(e) => {
|
|
910
|
+
e.stopPropagation();
|
|
911
|
+
},
|
|
912
|
+
{ passive: true }
|
|
913
|
+
);
|
|
914
|
+
bullet.addEventListener(BROWSER.CLICK, () => {
|
|
915
|
+
this._flicking.moveTo(panelIndex).catch((err) => {
|
|
1326
916
|
if (err instanceof FlickingError) return;
|
|
1327
917
|
throw err;
|
|
1328
918
|
});
|
|
1329
919
|
});
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
var __proto = BulletRenderer.prototype;
|
|
1349
|
-
Object.defineProperty(__proto, "_bulletClass", {
|
|
1350
|
-
get: function () {
|
|
1351
|
-
var pagination = this._pagination;
|
|
1352
|
-
return pagination.classPrefix + "-" + PAGINATION.BULLET_SUFFIX;
|
|
1353
|
-
},
|
|
1354
|
-
enumerable: false,
|
|
1355
|
-
configurable: true
|
|
1356
|
-
});
|
|
1357
|
-
Object.defineProperty(__proto, "_activeClass", {
|
|
1358
|
-
get: function () {
|
|
1359
|
-
var pagination = this._pagination;
|
|
1360
|
-
return pagination.classPrefix + "-" + PAGINATION.BULLET_ACTIVE_SUFFIX;
|
|
1361
|
-
},
|
|
1362
|
-
enumerable: false,
|
|
1363
|
-
configurable: true
|
|
1364
|
-
});
|
|
1365
|
-
|
|
1366
|
-
__proto.destroy = function () {
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
class BulletRenderer extends Renderer {
|
|
923
|
+
constructor() {
|
|
924
|
+
super(...arguments);
|
|
925
|
+
this._bullets = [];
|
|
926
|
+
this._prevIndex = -1;
|
|
927
|
+
}
|
|
928
|
+
get _bulletClass() {
|
|
929
|
+
const pagination = this._pagination;
|
|
930
|
+
return `${pagination.classPrefix}-${PAGINATION.BULLET_SUFFIX}`;
|
|
931
|
+
}
|
|
932
|
+
get _activeClass() {
|
|
933
|
+
const pagination = this._pagination;
|
|
934
|
+
return `${pagination.classPrefix}-${PAGINATION.BULLET_ACTIVE_SUFFIX}`;
|
|
935
|
+
}
|
|
936
|
+
destroy() {
|
|
1367
937
|
this._bullets = [];
|
|
1368
938
|
this._prevIndex = -1;
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
var renderActiveBullet = pagination.renderActiveBullet;
|
|
1381
|
-
var bulletWrapperClass = pagination.classPrefix + "-" + PAGINATION.BULLET_WRAPPER_SUFFIX;
|
|
1382
|
-
var anchorPoints = flicking.camera.anchorPoints;
|
|
939
|
+
}
|
|
940
|
+
render() {
|
|
941
|
+
const flicking = this._flicking;
|
|
942
|
+
const pagination = this._pagination;
|
|
943
|
+
const wrapper = this._wrapper;
|
|
944
|
+
const bulletClass = this._bulletClass;
|
|
945
|
+
const activeClass = this._activeClass;
|
|
946
|
+
const renderBullet = pagination.renderBullet;
|
|
947
|
+
const renderActiveBullet = pagination.renderActiveBullet;
|
|
948
|
+
const bulletWrapperClass = `${pagination.classPrefix}-${PAGINATION.BULLET_WRAPPER_SUFFIX}`;
|
|
949
|
+
const anchorPoints = flicking.camera.anchorPoints;
|
|
1383
950
|
addClass(wrapper, bulletWrapperClass);
|
|
1384
|
-
wrapper.innerHTML = anchorPoints.map(
|
|
951
|
+
wrapper.innerHTML = anchorPoints.map((anchorPoint, index) => {
|
|
1385
952
|
if (renderActiveBullet && anchorPoint.panel.index === flicking.index) {
|
|
1386
953
|
return renderActiveBullet(bulletClass, index);
|
|
1387
954
|
} else {
|
|
1388
955
|
return renderBullet(bulletClass, index);
|
|
1389
956
|
}
|
|
1390
957
|
}).join("\n");
|
|
1391
|
-
|
|
1392
|
-
bullets.forEach(
|
|
1393
|
-
|
|
1394
|
-
|
|
958
|
+
const bullets = [].slice.call(wrapper.children);
|
|
959
|
+
bullets.forEach((bullet, index) => {
|
|
960
|
+
const anchorPoint = anchorPoints[index];
|
|
1395
961
|
if (anchorPoint.panel.index === flicking.index) {
|
|
1396
962
|
addClass(bullet, activeClass);
|
|
1397
|
-
|
|
963
|
+
this._prevIndex = index;
|
|
1398
964
|
}
|
|
1399
|
-
|
|
1400
|
-
_this._addBulletEvents(bullet, index);
|
|
965
|
+
this._addBulletEvents(bullet, index);
|
|
1401
966
|
});
|
|
1402
967
|
this._bullets = bullets;
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
var renderActiveBullet = pagination.renderActiveBullet;
|
|
968
|
+
}
|
|
969
|
+
update(index) {
|
|
970
|
+
const flicking = this._flicking;
|
|
971
|
+
const pagination = this._pagination;
|
|
972
|
+
const wrapper = this._wrapper;
|
|
973
|
+
const bullets = this._bullets;
|
|
974
|
+
const bulletClass = this._bulletClass;
|
|
975
|
+
const activeClass = this._activeClass;
|
|
976
|
+
const prevIndex = this._prevIndex;
|
|
977
|
+
const anchorPoints = flicking.camera.anchorPoints;
|
|
978
|
+
const renderBullet = pagination.renderBullet;
|
|
979
|
+
const renderActiveBullet = pagination.renderActiveBullet;
|
|
1416
980
|
if (anchorPoints.length <= 0) return;
|
|
1417
|
-
|
|
1418
|
-
|
|
981
|
+
const anchorOffset = anchorPoints[0].panel.index;
|
|
982
|
+
const activeBulletIndex = index - anchorOffset;
|
|
1419
983
|
if (prevIndex === activeBulletIndex) return;
|
|
1420
|
-
|
|
1421
984
|
if (renderActiveBullet) {
|
|
1422
|
-
|
|
1423
|
-
|
|
985
|
+
const prevBullet = bullets[prevIndex];
|
|
1424
986
|
if (prevBullet) {
|
|
1425
|
-
|
|
1426
|
-
|
|
987
|
+
const newBullet = this._createBulletFromString(renderBullet(bulletClass, prevIndex), prevIndex);
|
|
1427
988
|
prevBullet.parentElement.replaceChild(newBullet, prevBullet);
|
|
1428
989
|
bullets[prevIndex] = newBullet;
|
|
1429
990
|
}
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
991
|
+
const activeBullet = bullets[activeBulletIndex];
|
|
992
|
+
const newActiveBullet = this._createBulletFromString(
|
|
993
|
+
renderActiveBullet(`${bulletClass} ${activeClass}`, activeBulletIndex),
|
|
994
|
+
activeBulletIndex
|
|
995
|
+
);
|
|
1435
996
|
wrapper.replaceChild(newActiveBullet, activeBullet);
|
|
1436
997
|
bullets[activeBulletIndex] = newActiveBullet;
|
|
1437
998
|
} else {
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
999
|
+
const activeBullet = bullets[activeBulletIndex];
|
|
1000
|
+
const prevBullet = bullets[prevIndex];
|
|
1441
1001
|
if (prevBullet) {
|
|
1442
1002
|
removeClass(prevBullet, activeClass);
|
|
1443
1003
|
}
|
|
1444
|
-
|
|
1445
1004
|
addClass(activeBullet, activeClass);
|
|
1446
1005
|
}
|
|
1447
|
-
|
|
1448
1006
|
this._prevIndex = activeBulletIndex;
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
function FractionRenderer() {
|
|
1460
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1461
|
-
|
|
1462
|
-
_this._prevIndex = -1;
|
|
1463
|
-
_this._prevTotal = -1;
|
|
1464
|
-
return _this;
|
|
1465
|
-
}
|
|
1466
|
-
|
|
1467
|
-
var __proto = FractionRenderer.prototype;
|
|
1468
|
-
|
|
1469
|
-
__proto.destroy = function () {
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
class FractionRenderer extends Renderer {
|
|
1010
|
+
constructor() {
|
|
1011
|
+
super(...arguments);
|
|
1012
|
+
this._prevIndex = -1;
|
|
1013
|
+
this._prevTotal = -1;
|
|
1014
|
+
}
|
|
1015
|
+
destroy() {
|
|
1470
1016
|
this._prevIndex = -1;
|
|
1471
1017
|
this._prevTotal = -1;
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
var fractionTotalClass = pagination.classPrefix + "-" + PAGINATION.FRACTION_TOTAL_SUFFIX;
|
|
1018
|
+
}
|
|
1019
|
+
render() {
|
|
1020
|
+
const flicking = this._flicking;
|
|
1021
|
+
const wrapper = this._wrapper;
|
|
1022
|
+
const pagination = this._pagination;
|
|
1023
|
+
const fractionWrapperClass = `${pagination.classPrefix}-${PAGINATION.FRACTION_WRAPPER_SUFFIX}`;
|
|
1024
|
+
const fractionCurrentClass = `${pagination.classPrefix}-${PAGINATION.FRACTION_CURRENT_SUFFIX}`;
|
|
1025
|
+
const fractionTotalClass = `${pagination.classPrefix}-${PAGINATION.FRACTION_TOTAL_SUFFIX}`;
|
|
1481
1026
|
addClass(wrapper, fractionWrapperClass);
|
|
1482
1027
|
wrapper.innerHTML = pagination.renderFraction(fractionCurrentClass, fractionTotalClass);
|
|
1483
1028
|
this.update(flicking.index);
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
var anchorCount = anchorPoints.length;
|
|
1029
|
+
}
|
|
1030
|
+
update(index) {
|
|
1031
|
+
const flicking = this._flicking;
|
|
1032
|
+
const wrapper = this._wrapper;
|
|
1033
|
+
const pagination = this._pagination;
|
|
1034
|
+
const anchorPoints = flicking.camera.anchorPoints;
|
|
1035
|
+
const currentIndex = anchorPoints.length > 0 ? index - anchorPoints[0].panel.index + 1 : 0;
|
|
1036
|
+
const anchorCount = anchorPoints.length;
|
|
1493
1037
|
if (currentIndex === this._prevIndex && anchorCount === this._prevTotal) return;
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1038
|
+
const fractionCurrentSelector = `.${pagination.classPrefix}-${PAGINATION.FRACTION_CURRENT_SUFFIX}`;
|
|
1039
|
+
const fractionTotalSelector = `.${pagination.classPrefix}-${PAGINATION.FRACTION_TOTAL_SUFFIX}`;
|
|
1040
|
+
const currentWrapper = wrapper.querySelector(fractionCurrentSelector);
|
|
1041
|
+
const totalWrapper = wrapper.querySelector(fractionTotalSelector);
|
|
1498
1042
|
currentWrapper.innerHTML = pagination.fractionCurrentFormat(currentIndex);
|
|
1499
1043
|
totalWrapper.innerHTML = pagination.fractionTotalFormat(anchorCount);
|
|
1500
1044
|
this._prevIndex = currentIndex;
|
|
1501
1045
|
this._prevTotal = anchorCount;
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
_this._sliderIndex = -1;
|
|
1519
|
-
|
|
1520
|
-
_this.moveTo = function (index) {
|
|
1521
|
-
var pagination = _this._pagination;
|
|
1522
|
-
var sliderEl = _this._wrapper.firstElementChild;
|
|
1523
|
-
var bulletSize = _this._bulletSize;
|
|
1524
|
-
var wrapperSize = bulletSize * pagination.bulletCount;
|
|
1525
|
-
sliderEl.style.transform = "translate(" + (wrapperSize / 2 - (index + 0.5) * bulletSize) + "px)";
|
|
1526
|
-
_this._sliderIndex = index;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
class ScrollBulletRenderer extends Renderer {
|
|
1049
|
+
constructor() {
|
|
1050
|
+
super(...arguments);
|
|
1051
|
+
this._bullets = [];
|
|
1052
|
+
this._bulletSize = 0;
|
|
1053
|
+
this._previousIndex = -1;
|
|
1054
|
+
this._sliderIndex = -1;
|
|
1055
|
+
this.moveTo = (index) => {
|
|
1056
|
+
const pagination = this._pagination;
|
|
1057
|
+
const sliderEl = this._wrapper.firstElementChild;
|
|
1058
|
+
const bulletSize = this._bulletSize;
|
|
1059
|
+
const wrapperSize = bulletSize * pagination.bulletCount;
|
|
1060
|
+
sliderEl.style.transform = `translate(${wrapperSize / 2 - (index + 0.5) * bulletSize}px)`;
|
|
1061
|
+
this._sliderIndex = index;
|
|
1527
1062
|
};
|
|
1528
|
-
|
|
1529
|
-
return _this;
|
|
1530
1063
|
}
|
|
1531
|
-
|
|
1532
|
-
var __proto = ScrollBulletRenderer.prototype;
|
|
1533
|
-
|
|
1534
|
-
__proto.destroy = function () {
|
|
1064
|
+
destroy() {
|
|
1535
1065
|
this._bullets = [];
|
|
1536
1066
|
this._bulletSize = 0;
|
|
1537
1067
|
this._previousIndex = -1;
|
|
1538
1068
|
this._sliderIndex = -1;
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
var sliderClass = pagination.classPrefix + "-" + PAGINATION.SCROLL_SLIDER_SUFFIX;
|
|
1552
|
-
var uninitClass = pagination.classPrefix + "-" + PAGINATION.SCROLL_UNINIT_SUFFIX;
|
|
1553
|
-
var sliderEl = document.createElement("div");
|
|
1069
|
+
}
|
|
1070
|
+
render() {
|
|
1071
|
+
const wrapper = this._wrapper;
|
|
1072
|
+
const flicking = this._flicking;
|
|
1073
|
+
const pagination = this._pagination;
|
|
1074
|
+
const renderBullet = pagination.renderBullet;
|
|
1075
|
+
const anchorPoints = flicking.camera.anchorPoints;
|
|
1076
|
+
const dynamicWrapperClass = `${pagination.classPrefix}-${PAGINATION.SCROLL_WRAPPER_SUFFIX}`;
|
|
1077
|
+
const bulletClass = `${pagination.classPrefix}-${PAGINATION.BULLET_SUFFIX}`;
|
|
1078
|
+
const sliderClass = `${pagination.classPrefix}-${PAGINATION.SCROLL_SLIDER_SUFFIX}`;
|
|
1079
|
+
const uninitClass = `${pagination.classPrefix}-${PAGINATION.SCROLL_UNINIT_SUFFIX}`;
|
|
1080
|
+
const sliderEl = document.createElement("div");
|
|
1554
1081
|
addClass(sliderEl, sliderClass);
|
|
1555
1082
|
addClass(wrapper, uninitClass);
|
|
1556
1083
|
addClass(wrapper, dynamicWrapperClass);
|
|
1557
1084
|
wrapper.appendChild(sliderEl);
|
|
1558
|
-
sliderEl.innerHTML = anchorPoints.map(
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
bullets.forEach(function (bullet, index) {
|
|
1563
|
-
_this._addBulletEvents(bullet, index);
|
|
1085
|
+
sliderEl.innerHTML = anchorPoints.map((_, index) => renderBullet(bulletClass, index)).join("\n");
|
|
1086
|
+
const bullets = [].slice.call(sliderEl.children);
|
|
1087
|
+
bullets.forEach((bullet, index) => {
|
|
1088
|
+
this._addBulletEvents(bullet, index);
|
|
1564
1089
|
});
|
|
1565
1090
|
if (bullets.length <= 0) return;
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
wrapper.style.width = bulletSize * pagination.bulletCount
|
|
1091
|
+
const bulletStyle = getComputedStyle(bullets[0]);
|
|
1092
|
+
const bulletSize = bullets[0].clientWidth + parseFloat(bulletStyle.marginLeft) + parseFloat(bulletStyle.marginRight);
|
|
1093
|
+
wrapper.style.width = `${bulletSize * pagination.bulletCount}px`;
|
|
1569
1094
|
this._bullets = bullets;
|
|
1570
1095
|
this._bulletSize = bulletSize;
|
|
1571
1096
|
this._previousIndex = -1;
|
|
1572
1097
|
this.update(this._flicking.index);
|
|
1573
|
-
window.requestAnimationFrame(
|
|
1098
|
+
window.requestAnimationFrame(() => {
|
|
1574
1099
|
removeClass(wrapper, uninitClass);
|
|
1575
1100
|
});
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
var activeIndex = index - anchorOffset;
|
|
1101
|
+
}
|
|
1102
|
+
update(index) {
|
|
1103
|
+
const pagination = this._pagination;
|
|
1104
|
+
const flicking = this._flicking;
|
|
1105
|
+
const bullets = this._bullets;
|
|
1106
|
+
const prevIndex = this._previousIndex;
|
|
1107
|
+
const renderBullet = pagination.renderBullet;
|
|
1108
|
+
const renderActiveBullet = pagination.renderActiveBullet;
|
|
1109
|
+
const anchorPoints = flicking.camera.anchorPoints;
|
|
1110
|
+
const anchorOffset = anchorPoints[0].panel.index;
|
|
1111
|
+
const activeIndex = index - anchorOffset;
|
|
1588
1112
|
if (anchorPoints.length <= 0) return;
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
};
|
|
1597
|
-
|
|
1598
|
-
var bulletNextClass = function (offset) {
|
|
1599
|
-
return "" + nextClassPrefix + (offset > 1 ? offset : "");
|
|
1600
|
-
};
|
|
1601
|
-
|
|
1602
|
-
var prevClassRegex = new RegExp("^" + prevClassPrefix);
|
|
1603
|
-
var nextClassRegex = new RegExp("^" + nextClassPrefix);
|
|
1604
|
-
|
|
1113
|
+
const bulletClass = `${pagination.classPrefix}-${PAGINATION.BULLET_SUFFIX}`;
|
|
1114
|
+
const bulletActiveClass = `${pagination.classPrefix}-${PAGINATION.BULLET_ACTIVE_SUFFIX}`;
|
|
1115
|
+
const prevClassPrefix = `${pagination.classPrefix}-${PAGINATION.SCROLL_PREV_SUFFIX}`;
|
|
1116
|
+
const nextClassPrefix = `${pagination.classPrefix}-${PAGINATION.SCROLL_NEXT_SUFFIX}`;
|
|
1117
|
+
const bulletPrevClass = (offset) => `${prevClassPrefix}${offset > 1 ? offset : ""}`;
|
|
1118
|
+
const bulletNextClass = (offset) => `${nextClassPrefix}${offset > 1 ? offset : ""}`;
|
|
1119
|
+
const prevClassRegex = new RegExp(`^${prevClassPrefix}`);
|
|
1120
|
+
const nextClassRegex = new RegExp(`^${nextClassPrefix}`);
|
|
1605
1121
|
if (renderActiveBullet) {
|
|
1606
|
-
|
|
1607
|
-
|
|
1122
|
+
const prevBullet = bullets[prevIndex];
|
|
1608
1123
|
if (prevBullet) {
|
|
1609
|
-
|
|
1610
|
-
|
|
1124
|
+
const newBullet = this._createBulletFromString(renderBullet(bulletClass, prevIndex), prevIndex);
|
|
1611
1125
|
prevBullet.parentElement.replaceChild(newBullet, prevBullet);
|
|
1612
1126
|
bullets[prevIndex] = newBullet;
|
|
1613
1127
|
}
|
|
1614
|
-
|
|
1615
|
-
var activeBullet = bullets[activeIndex];
|
|
1616
|
-
|
|
1128
|
+
const activeBullet = bullets[activeIndex];
|
|
1617
1129
|
if (activeBullet) {
|
|
1618
|
-
|
|
1619
|
-
|
|
1130
|
+
const newActiveBullet = this._createBulletFromString(renderActiveBullet(bulletClass, activeIndex), activeIndex);
|
|
1620
1131
|
activeBullet.parentElement.replaceChild(newActiveBullet, activeBullet);
|
|
1621
1132
|
bullets[activeIndex] = newActiveBullet;
|
|
1622
1133
|
}
|
|
1623
1134
|
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
for (var _i = 0, classList_1 = classList; _i < classList_1.length; _i++) {
|
|
1630
|
-
var className = classList_1[_i];
|
|
1631
|
-
|
|
1135
|
+
bullets.forEach((bullet, idx) => {
|
|
1136
|
+
const indexOffset = idx - activeIndex;
|
|
1137
|
+
const classList = bullet.className.split(" ");
|
|
1138
|
+
for (const className of classList) {
|
|
1632
1139
|
if (className === bulletActiveClass || prevClassRegex.test(className) || nextClassRegex.test(className)) {
|
|
1633
1140
|
removeClass(bullet, className);
|
|
1634
1141
|
}
|
|
1635
1142
|
}
|
|
1636
|
-
|
|
1637
1143
|
if (indexOffset === 0) {
|
|
1638
1144
|
addClass(bullet, bulletActiveClass);
|
|
1639
1145
|
} else if (indexOffset > 0) {
|
|
@@ -1644,76 +1150,45 @@ function (_super) {
|
|
|
1644
1150
|
});
|
|
1645
1151
|
pagination.scrollOnChange(activeIndex, {
|
|
1646
1152
|
total: bullets.length,
|
|
1647
|
-
prevIndex
|
|
1153
|
+
prevIndex,
|
|
1648
1154
|
sliderIndex: this._sliderIndex,
|
|
1649
1155
|
direction: activeIndex > prevIndex ? DIRECTION.NEXT : DIRECTION.PREV,
|
|
1650
|
-
bullets:
|
|
1156
|
+
bullets: [...bullets],
|
|
1651
1157
|
moveTo: this.moveTo
|
|
1652
1158
|
});
|
|
1653
1159
|
this._previousIndex = activeIndex;
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
function () {
|
|
1666
|
-
function Pagination(_a) {
|
|
1667
|
-
var _this = this;
|
|
1668
|
-
|
|
1669
|
-
var _b = _a === void 0 ? {} : _a,
|
|
1670
|
-
_c = _b.parentEl,
|
|
1671
|
-
parentEl = _c === void 0 ? null : _c,
|
|
1672
|
-
_d = _b.selector,
|
|
1673
|
-
selector = _d === void 0 ? PAGINATION.SELECTOR : _d,
|
|
1674
|
-
_e = _b.type,
|
|
1675
|
-
type = _e === void 0 ? PAGINATION.TYPE.BULLET : _e,
|
|
1676
|
-
_f = _b.classPrefix,
|
|
1677
|
-
classPrefix = _f === void 0 ? PAGINATION.PREFIX : _f,
|
|
1678
|
-
_g = _b.bulletCount,
|
|
1679
|
-
bulletCount = _g === void 0 ? 5 : _g,
|
|
1680
|
-
_h = _b.renderBullet,
|
|
1681
|
-
renderBullet = _h === void 0 ? function (className) {
|
|
1682
|
-
return "<span class=\"" + className + "\"></span>";
|
|
1683
|
-
} : _h,
|
|
1684
|
-
_j = _b.renderActiveBullet,
|
|
1685
|
-
renderActiveBullet = _j === void 0 ? null : _j,
|
|
1686
|
-
_k = _b.renderFraction,
|
|
1687
|
-
renderFraction = _k === void 0 ? function (currentClass, totalClass) {
|
|
1688
|
-
return "<span class=\"" + currentClass + "\"></span>/<span class=\"" + totalClass + "\"></span>";
|
|
1689
|
-
} : _k,
|
|
1690
|
-
_l = _b.fractionCurrentFormat,
|
|
1691
|
-
fractionCurrentFormat = _l === void 0 ? function (index) {
|
|
1692
|
-
return index.toString();
|
|
1693
|
-
} : _l,
|
|
1694
|
-
_m = _b.fractionTotalFormat,
|
|
1695
|
-
fractionTotalFormat = _m === void 0 ? function (index) {
|
|
1696
|
-
return index.toString();
|
|
1697
|
-
} : _m,
|
|
1698
|
-
_o = _b.scrollOnChange,
|
|
1699
|
-
scrollOnChange = _o === void 0 ? function (index, ctx) {
|
|
1700
|
-
return ctx.moveTo(index);
|
|
1701
|
-
} : _o;
|
|
1702
|
-
/* Internal Values */
|
|
1703
|
-
|
|
1704
|
-
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
class Pagination {
|
|
1163
|
+
/**
|
|
1164
|
+
* @param options - Options for the Pagination instance
|
|
1165
|
+
* @example
|
|
1166
|
+
* ```ts
|
|
1167
|
+
* flicking.addPlugins(new Pagination({ type: "bullet", selector: ".flicking-pagination" }));
|
|
1168
|
+
* ```
|
|
1169
|
+
*/
|
|
1170
|
+
constructor(options = {}) {
|
|
1705
1171
|
this._flicking = null;
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
_this._renderer.render();
|
|
1172
|
+
this.update = () => {
|
|
1173
|
+
this._removeAllChilds();
|
|
1174
|
+
this._renderer.render();
|
|
1711
1175
|
};
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
_this._renderer.update(evt.index);
|
|
1176
|
+
this._onIndexChange = (evt) => {
|
|
1177
|
+
this._renderer.update(evt.index);
|
|
1715
1178
|
};
|
|
1716
|
-
|
|
1179
|
+
const {
|
|
1180
|
+
parentEl = null,
|
|
1181
|
+
selector = PAGINATION.SELECTOR,
|
|
1182
|
+
type = PAGINATION.TYPE.BULLET,
|
|
1183
|
+
classPrefix = PAGINATION.PREFIX,
|
|
1184
|
+
bulletCount = 5,
|
|
1185
|
+
renderBullet = (className) => `<span class="${className}"></span>`,
|
|
1186
|
+
renderActiveBullet = null,
|
|
1187
|
+
renderFraction = (currentClass, totalClass) => `<span class="${currentClass}"></span>/<span class="${totalClass}"></span>`,
|
|
1188
|
+
fractionCurrentFormat = (index) => index.toString(),
|
|
1189
|
+
fractionTotalFormat = (index) => index.toString(),
|
|
1190
|
+
scrollOnChange = (index, ctx) => ctx.moveTo(index)
|
|
1191
|
+
} = options;
|
|
1717
1192
|
this._parentEl = parentEl;
|
|
1718
1193
|
this._selector = selector;
|
|
1719
1194
|
this._type = type;
|
|
@@ -1726,200 +1201,163 @@ function () {
|
|
|
1726
1201
|
this._fractionTotalFormat = fractionTotalFormat;
|
|
1727
1202
|
this._scrollOnChange = scrollOnChange;
|
|
1728
1203
|
}
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
},
|
|
1822
|
-
set: function (val) {
|
|
1823
|
-
this._fractionTotalFormat = val;
|
|
1824
|
-
},
|
|
1825
|
-
enumerable: false,
|
|
1826
|
-
configurable: true
|
|
1827
|
-
});
|
|
1828
|
-
Object.defineProperty(__proto, "scrollOnChange", {
|
|
1829
|
-
get: function () {
|
|
1830
|
-
return this._scrollOnChange;
|
|
1831
|
-
},
|
|
1832
|
-
set: function (val) {
|
|
1833
|
-
this._scrollOnChange = val;
|
|
1834
|
-
},
|
|
1835
|
-
enumerable: false,
|
|
1836
|
-
configurable: true
|
|
1837
|
-
});
|
|
1838
|
-
Object.defineProperty(__proto, "bulletWrapperclassPrefixClass", {
|
|
1839
|
-
set: function (val) {
|
|
1840
|
-
this._classPrefix = val;
|
|
1841
|
-
},
|
|
1842
|
-
enumerable: false,
|
|
1843
|
-
configurable: true
|
|
1844
|
-
});
|
|
1845
|
-
|
|
1846
|
-
__proto.init = function (flicking) {
|
|
1204
|
+
/** Current value of the {@link PaginationOptions.parentEl | parentEl} option. */
|
|
1205
|
+
get parentEl() {
|
|
1206
|
+
return this._parentEl;
|
|
1207
|
+
}
|
|
1208
|
+
/** Current value of the {@link PaginationOptions.selector | selector} option. */
|
|
1209
|
+
get selector() {
|
|
1210
|
+
return this._selector;
|
|
1211
|
+
}
|
|
1212
|
+
/** Current value of the {@link PaginationOptions.type | type} option. */
|
|
1213
|
+
get type() {
|
|
1214
|
+
return this._type;
|
|
1215
|
+
}
|
|
1216
|
+
/** Current value of the {@link PaginationOptions.classPrefix | classPrefix} option. */
|
|
1217
|
+
get classPrefix() {
|
|
1218
|
+
return this._classPrefix;
|
|
1219
|
+
}
|
|
1220
|
+
/** Current value of the {@link PaginationOptions.bulletCount | bulletCount} option. */
|
|
1221
|
+
get bulletCount() {
|
|
1222
|
+
return this._bulletCount;
|
|
1223
|
+
}
|
|
1224
|
+
/** Current value of the {@link PaginationOptions.renderBullet | renderBullet} option. */
|
|
1225
|
+
get renderBullet() {
|
|
1226
|
+
return this._renderBullet;
|
|
1227
|
+
}
|
|
1228
|
+
/** Current value of the {@link PaginationOptions.renderActiveBullet | renderActiveBullet} option. */
|
|
1229
|
+
get renderActiveBullet() {
|
|
1230
|
+
return this._renderActiveBullet;
|
|
1231
|
+
}
|
|
1232
|
+
/** Current value of the {@link PaginationOptions.renderFraction | renderFraction} option. */
|
|
1233
|
+
get renderFraction() {
|
|
1234
|
+
return this._renderFraction;
|
|
1235
|
+
}
|
|
1236
|
+
/** Current value of the {@link PaginationOptions.fractionCurrentFormat | fractionCurrentFormat} option. */
|
|
1237
|
+
get fractionCurrentFormat() {
|
|
1238
|
+
return this._fractionCurrentFormat;
|
|
1239
|
+
}
|
|
1240
|
+
/** Current value of the {@link PaginationOptions.fractionTotalFormat | fractionTotalFormat} option. */
|
|
1241
|
+
get fractionTotalFormat() {
|
|
1242
|
+
return this._fractionTotalFormat;
|
|
1243
|
+
}
|
|
1244
|
+
/** Current value of the {@link PaginationOptions.scrollOnChange | scrollOnChange} option. */
|
|
1245
|
+
get scrollOnChange() {
|
|
1246
|
+
return this._scrollOnChange;
|
|
1247
|
+
}
|
|
1248
|
+
/** Sets {@link PaginationOptions.parentEl | parentEl}. */
|
|
1249
|
+
set parentEl(val) {
|
|
1250
|
+
this._parentEl = val;
|
|
1251
|
+
}
|
|
1252
|
+
/** Sets {@link PaginationOptions.selector | selector}. */
|
|
1253
|
+
set selector(val) {
|
|
1254
|
+
this._selector = val;
|
|
1255
|
+
}
|
|
1256
|
+
/** Sets {@link PaginationOptions.type | type}. */
|
|
1257
|
+
set type(val) {
|
|
1258
|
+
this._type = val;
|
|
1259
|
+
}
|
|
1260
|
+
/** Sets {@link PaginationOptions.classPrefix | classPrefix}. */
|
|
1261
|
+
set bulletWrapperclassPrefixClass(val) {
|
|
1262
|
+
this._classPrefix = val;
|
|
1263
|
+
}
|
|
1264
|
+
/** Sets {@link PaginationOptions.bulletCount | bulletCount}. */
|
|
1265
|
+
set bulletCount(val) {
|
|
1266
|
+
this._bulletCount = val;
|
|
1267
|
+
}
|
|
1268
|
+
/** Sets {@link PaginationOptions.renderBullet | renderBullet}. */
|
|
1269
|
+
set renderBullet(val) {
|
|
1270
|
+
this._renderBullet = val;
|
|
1271
|
+
}
|
|
1272
|
+
/** Sets {@link PaginationOptions.renderActiveBullet | renderActiveBullet}. */
|
|
1273
|
+
set renderActiveBullet(val) {
|
|
1274
|
+
this._renderActiveBullet = val;
|
|
1275
|
+
}
|
|
1276
|
+
/** Sets {@link PaginationOptions.renderFraction | renderFraction}. */
|
|
1277
|
+
set renderFraction(val) {
|
|
1278
|
+
this._renderFraction = val;
|
|
1279
|
+
}
|
|
1280
|
+
/** Sets {@link PaginationOptions.fractionCurrentFormat | fractionCurrentFormat}. */
|
|
1281
|
+
set fractionCurrentFormat(val) {
|
|
1282
|
+
this._fractionCurrentFormat = val;
|
|
1283
|
+
}
|
|
1284
|
+
/** Sets {@link PaginationOptions.fractionTotalFormat | fractionTotalFormat}. */
|
|
1285
|
+
set fractionTotalFormat(val) {
|
|
1286
|
+
this._fractionTotalFormat = val;
|
|
1287
|
+
}
|
|
1288
|
+
/** Sets {@link PaginationOptions.scrollOnChange | scrollOnChange}. */
|
|
1289
|
+
set scrollOnChange(val) {
|
|
1290
|
+
this._scrollOnChange = val;
|
|
1291
|
+
}
|
|
1292
|
+
/** Initialize the plugin, create the pagination renderer, and attach event listeners to the Flicking instance.
|
|
1293
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
1294
|
+
*/
|
|
1295
|
+
init(flicking) {
|
|
1847
1296
|
if (this._flicking) {
|
|
1848
1297
|
this.destroy();
|
|
1849
1298
|
}
|
|
1850
|
-
|
|
1851
1299
|
this._flicking = flicking;
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1300
|
+
const type = this._type;
|
|
1301
|
+
const selector = this._selector;
|
|
1302
|
+
const parentEl = this._parentEl ? this._parentEl : flicking.element;
|
|
1303
|
+
const wrapper = parentEl.querySelector(selector);
|
|
1857
1304
|
if (!wrapper) {
|
|
1858
|
-
throw new Error(
|
|
1305
|
+
throw new Error(`[Flicking-Pagination] Couldn't find element with the given selector: ${selector}`);
|
|
1859
1306
|
}
|
|
1860
|
-
|
|
1861
1307
|
this._wrapper = wrapper;
|
|
1862
1308
|
this._renderer = this._createRenderer(type);
|
|
1863
1309
|
flicking.on(EVENTS.WILL_CHANGE, this._onIndexChange);
|
|
1864
1310
|
flicking.on(EVENTS.WILL_RESTORE, this._onIndexChange);
|
|
1865
1311
|
flicking.on(EVENTS.PANEL_CHANGE, this.update);
|
|
1866
1312
|
this.update();
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1313
|
+
}
|
|
1314
|
+
/** Destroy the plugin, remove all event listeners, and clean up pagination DOM elements. */
|
|
1315
|
+
destroy() {
|
|
1316
|
+
const flicking = this._flicking;
|
|
1872
1317
|
if (!flicking) {
|
|
1873
1318
|
return;
|
|
1874
1319
|
}
|
|
1875
|
-
|
|
1876
1320
|
flicking.off(EVENTS.WILL_CHANGE, this._onIndexChange);
|
|
1877
1321
|
flicking.off(EVENTS.WILL_RESTORE, this._onIndexChange);
|
|
1878
1322
|
flicking.off(EVENTS.PANEL_CHANGE, this.update);
|
|
1879
|
-
|
|
1880
1323
|
this._renderer.destroy();
|
|
1881
|
-
|
|
1882
1324
|
this._removeAllChilds();
|
|
1883
|
-
|
|
1884
1325
|
this._flicking = null;
|
|
1885
|
-
}
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
var options = {
|
|
1326
|
+
}
|
|
1327
|
+
_createRenderer(type) {
|
|
1328
|
+
const options = {
|
|
1889
1329
|
flicking: this._flicking,
|
|
1890
1330
|
pagination: this,
|
|
1891
1331
|
wrapper: this._wrapper
|
|
1892
1332
|
};
|
|
1893
|
-
|
|
1894
1333
|
switch (type) {
|
|
1895
1334
|
case PAGINATION.TYPE.BULLET:
|
|
1896
1335
|
return new BulletRenderer(options);
|
|
1897
|
-
|
|
1898
1336
|
case PAGINATION.TYPE.FRACTION:
|
|
1899
1337
|
return new FractionRenderer(options);
|
|
1900
|
-
|
|
1901
1338
|
case PAGINATION.TYPE.SCROLL:
|
|
1902
1339
|
return new ScrollBulletRenderer(options);
|
|
1903
|
-
|
|
1904
1340
|
default:
|
|
1905
|
-
throw new Error(
|
|
1341
|
+
throw new Error(`[Flicking-Pagination] type "${type}" is not supported.`);
|
|
1906
1342
|
}
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
var wrapper = this._wrapper;
|
|
1911
|
-
|
|
1343
|
+
}
|
|
1344
|
+
_removeAllChilds() {
|
|
1345
|
+
const wrapper = this._wrapper;
|
|
1912
1346
|
while (wrapper.firstChild) {
|
|
1913
1347
|
wrapper.removeChild(wrapper.firstChild);
|
|
1914
1348
|
}
|
|
1915
|
-
}
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
export {
|
|
1352
|
+
ARROW,
|
|
1353
|
+
Arrow,
|
|
1354
|
+
AutoPlay,
|
|
1355
|
+
Fade,
|
|
1356
|
+
PAGINATION,
|
|
1357
|
+
Pagination,
|
|
1358
|
+
Parallax,
|
|
1359
|
+
Perspective,
|
|
1360
|
+
SYNC,
|
|
1361
|
+
Sync
|
|
1362
|
+
};
|
|
1925
1363
|
//# sourceMappingURL=plugins.esm.js.map
|