@egjs/flicking-plugins 4.7.2-beta.1 → 4.7.2-beta.10

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