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