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