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