@egjs/flicking-plugins 4.7.0 → 4.8.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/plugins.js CHANGED
@@ -4,7 +4,7 @@ name: @egjs/flicking-plugins
4
4
  license: MIT
5
5
  author: NAVER Corp.
6
6
  repository: https://github.com/naver/egjs-flicking-plugins
7
- version: 4.7.0
7
+ version: 4.8.0-beta.0
8
8
  */
9
9
  (function (global, factory) {
10
10
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@egjs/flicking')) :
@@ -12,22 +12,22 @@ version: 4.7.0
12
12
  (global = global || self, factory((global.Flicking = global.Flicking || {}, global.Flicking.Plugins = {}), global.Flicking));
13
13
  }(this, function (exports, flicking) { 'use strict';
14
14
 
15
- /**
16
- * You can apply parallax effect while panel is moving.
17
- * @ko 패널들을 움직이면서 parallax 효과를 부여할 수 있습니다.
18
- * @memberof Flicking.Plugins
15
+ /**
16
+ * You can apply parallax effect while panel is moving.
17
+ * @ko 패널들을 움직이면서 parallax 효과를 부여할 수 있습니다.
18
+ * @memberof Flicking.Plugins
19
19
  */
20
20
 
21
21
  var Parallax =
22
22
  /*#__PURE__*/
23
23
  function () {
24
- /**
25
- * @param {string} selector Selector of the element to apply parallax effect<ko> Parallax 효과를 적용할 엘리먼트의 선택자 </ko>
26
- * @param {number} scale Effect amplication scale<ko>효과 증폭도</ko>
27
- * @example
28
- * ```ts
29
- * flicking.addPlugins(new Parallax("img", 1));
30
- * ```
24
+ /**
25
+ * @param {string} selector Selector of the element to apply parallax effect<ko> Parallax 효과를 적용할 엘리먼트의 선택자 </ko>
26
+ * @param {number} scale Effect amplication scale<ko>효과 증폭도</ko>
27
+ * @example
28
+ * ```ts
29
+ * flicking.addPlugins(new Parallax("img", 1));
30
+ * ```
31
31
  */
32
32
  function Parallax(selector, scale) {
33
33
  var _this = this;
@@ -114,22 +114,22 @@ version: 4.7.0
114
114
  return Parallax;
115
115
  }();
116
116
 
117
- /**
118
- * You can apply fade in / out effect while panel is moving.
119
- * @ko 패널들을 움직이면서 fade in / out 효과를 부여할 수 있습니다.
120
- * @memberof Flicking.Plugins
117
+ /**
118
+ * You can apply fade in / out effect while panel is moving.
119
+ * @ko 패널들을 움직이면서 fade in / out 효과를 부여할 수 있습니다.
120
+ * @memberof Flicking.Plugins
121
121
  */
122
122
 
123
123
  var Fade =
124
124
  /*#__PURE__*/
125
125
  function () {
126
- /**
127
- * @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>
128
- * @param - Effect amplication scale<ko>효과 증폭도</ko>
129
- * @example
130
- * ```ts
131
- * flicking.addPlugins(new Fade("p", 1));
132
- * ```
126
+ /**
127
+ * @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>
128
+ * @param - Effect amplication scale<ko>효과 증폭도</ko>
129
+ * @example
130
+ * ```ts
131
+ * flicking.addPlugins(new Fade("p", 1));
132
+ * ```
133
133
  */
134
134
  function Fade(selector, scale) {
135
135
  var _this = this;
@@ -216,26 +216,26 @@ version: 4.7.0
216
216
  return Fade;
217
217
  }();
218
218
 
219
- /**
220
- * Plugin that allow you to automatically move to the next/previous panel, on a specific time basis
221
- * @ko 일정 시간마다, 자동으로 다음/이전 패널로 넘어가도록 할 수 있는 플러그인
222
- * @memberof Flicking.Plugins
219
+ /**
220
+ * Plugin that allow you to automatically move to the next/previous panel, on a specific time basis
221
+ * @ko 일정 시간마다, 자동으로 다음/이전 패널로 넘어가도록 할 수 있는 플러그인
222
+ * @memberof Flicking.Plugins
223
223
  */
224
224
 
225
225
  var AutoPlay =
226
226
  /*#__PURE__*/
227
227
  function () {
228
- /**
229
- * @param {AutoPlayOptions} options Options for the AutoPlay instance.<ko>AutoPlay 옵션</ko>
230
- * @param {number} options.duration Time to wait before moving on to the next panel.<ko>다음 패널로 움직이기까지 대기 시간</ko>
231
- * @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>
232
- * @param {"PREV" | "NEXT"} options.direction The direction in which the panel moves.<ko>패널이 움직이는 방향</ko>
233
- * @param {boolean} options.stopOnHover Whether to stop when mouse hover upon the element.<ko>엘리먼트에 마우스를 올렸을 때 AutoPlay를 정지할지 여부</ko>
234
- * @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>
235
- * @example
236
- * ```ts
237
- * flicking.addPlugins(new AutoPlay({ duration: 2000, direction: "NEXT" }));
238
- * ```
228
+ /**
229
+ * @param {AutoPlayOptions} options Options for the AutoPlay instance.<ko>AutoPlay 옵션</ko>
230
+ * @param {number} options.duration Time to wait before moving on to the next panel.<ko>다음 패널로 움직이기까지 대기 시간</ko>
231
+ * @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>
232
+ * @param {"PREV" | "NEXT"} options.direction The direction in which the panel moves.<ko>패널이 움직이는 방향</ko>
233
+ * @param {boolean} options.stopOnHover Whether to stop when mouse hover upon the element.<ko>엘리먼트에 마우스를 올렸을 때 AutoPlay를 정지할지 여부</ko>
234
+ * @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>
235
+ * @example
236
+ * ```ts
237
+ * flicking.addPlugins(new AutoPlay({ duration: 2000, direction: "NEXT" }));
238
+ * ```
239
239
  */
240
240
  function AutoPlay(_a) {
241
241
  var _this = this;
@@ -404,12 +404,61 @@ version: 4.7.0
404
404
 
405
405
  this._playing = true;
406
406
  this._timerId = window.setTimeout(function () {
407
+ var _a, _b;
408
+
409
+ var animationDuration = _this._animationDuration || flicking$1.duration;
410
+ var moveType = flicking$1.moveType; // for freeScroll
411
+
412
+ if (moveType === flicking.MOVE_TYPE.FREE_SCROLL || (moveType === null || moveType === void 0 ? void 0 : moveType[0]) === flicking.MOVE_TYPE.FREE_SCROLL) {
413
+ var range = flicking$1.camera.range;
414
+ var cameraPosition = flicking$1.camera.position;
415
+ var currentPanel = flicking$1.currentPanel;
416
+ var prevPanel = currentPanel.prev();
417
+ var nextPanel = currentPanel.next();
418
+ var currentPosition = currentPanel.position;
419
+ var nextPosition = (_a = nextPanel === null || nextPanel === void 0 ? void 0 : nextPanel.position) !== null && _a !== void 0 ? _a : range.max;
420
+ 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)
421
+
422
+ if (prevPosition > currentPosition) {
423
+ prevPosition = range.min - (range.max - prevPosition);
424
+ } // current (last) > next (0)
425
+
426
+
427
+ if (nextPosition < currentPosition) {
428
+ nextPosition += range.max;
429
+ }
430
+
431
+ if (direction === flicking.DIRECTION.NEXT) {
432
+ // prev - cur - camera - next
433
+ var size = nextPosition - currentPosition;
434
+ var restSize = nextPosition - cameraPosition;
435
+
436
+ if (cameraPosition < currentPosition) {
437
+ // prev - camera - cur - next
438
+ restSize = nextPosition - cameraPosition;
439
+ }
440
+
441
+ animationDuration *= restSize / size;
442
+ } else {
443
+ // prev - caemra - cur - next
444
+ var size = currentPosition - prevPosition;
445
+ var restSize = cameraPosition - prevPosition;
446
+
447
+ if (cameraPosition > currentPosition) {
448
+ // prev - cur - camera - next
449
+ restSize = cameraPosition - prevPosition;
450
+ }
451
+
452
+ animationDuration *= restSize / size;
453
+ }
454
+ }
455
+
407
456
  if (direction === flicking.DIRECTION.NEXT) {
408
- flicking$1.next(_this._animationDuration).catch(function () {
457
+ flicking$1.next(animationDuration).catch(function () {
409
458
  return void 0;
410
459
  });
411
460
  } else {
412
- flicking$1.prev(_this._animationDuration).catch(function () {
461
+ flicking$1.prev(animationDuration).catch(function () {
413
462
  return void 0;
414
463
  });
415
464
  }
@@ -492,10 +541,10 @@ version: 4.7.0
492
541
  return el;
493
542
  };
494
543
 
495
- /**
496
- * A plugin to easily create prev/right arrow button of Flicking
497
- * @ko 이전/다음 버튼을 쉽게 만들 수 있는 플러그인
498
- * @memberof Flicking.Plugins
544
+ /**
545
+ * A plugin to easily create prev/right arrow button of Flicking
546
+ * @ko 이전/다음 버튼을 쉽게 만들 수 있는 플러그인
547
+ * @memberof Flicking.Plugins
499
548
  */
500
549
 
501
550
  var Arrow =
@@ -516,7 +565,9 @@ version: 4.7.0
516
565
  _g = _b.moveCount,
517
566
  moveCount = _g === void 0 ? 1 : _g,
518
567
  _h = _b.moveByViewportSize,
519
- moveByViewportSize = _h === void 0 ? false : _h;
568
+ moveByViewportSize = _h === void 0 ? false : _h,
569
+ _j = _b.interruptable,
570
+ interruptable = _j === void 0 ? false : _j;
520
571
  /* Internal Values */
521
572
 
522
573
 
@@ -528,9 +579,16 @@ version: 4.7.0
528
579
 
529
580
  this._onPrevClick = function () {
530
581
  var flicking = _this._flicking;
582
+ var index = flicking.animating ? _this._nextIndex : flicking.index;
583
+ var currentPanel = flicking.animating ? flicking.panels[_this._nextIndex] : flicking.currentPanel;
531
584
  var camera = flicking.camera;
532
585
  var anchorPoints = camera.anchorPoints;
533
- if (flicking.animating || anchorPoints.length <= 0) return;
586
+ if (flicking.animating && !_this.interruptable || anchorPoints.length <= 0) return;
587
+
588
+ if (flicking.animating) {
589
+ flicking.stopAnimation();
590
+ }
591
+
534
592
  var firstAnchor = anchorPoints[0];
535
593
  var moveCount = _this._moveCount;
536
594
 
@@ -538,26 +596,33 @@ version: 4.7.0
538
596
  flicking.control.moveToPosition(camera.position - camera.size, flicking.duration).catch(_this._onCatch);
539
597
  } else {
540
598
  if (flicking.circularEnabled) {
541
- var targetPanel = flicking.currentPanel;
599
+ var targetPanel = currentPanel;
542
600
 
543
601
  for (var i = 0; i < moveCount; i++) {
544
602
  targetPanel = targetPanel.prev();
545
603
  }
546
604
 
547
605
  targetPanel.focus().catch(_this._onCatch);
548
- } else if (flicking.index > firstAnchor.panel.index) {
549
- flicking.moveTo(Math.max(flicking.index - moveCount, firstAnchor.panel.index)).catch(_this._onCatch);
606
+ } else if (index > firstAnchor.panel.index) {
607
+ flicking.moveTo(Math.max(index - moveCount, firstAnchor.panel.index)).catch(_this._onCatch);
550
608
  } else if (camera.position > camera.range.min) {
551
- flicking.moveTo(flicking.index).catch(_this._onCatch);
609
+ flicking.moveTo(index).catch(_this._onCatch);
552
610
  }
553
611
  }
554
612
  };
555
613
 
556
614
  this._onNextClick = function () {
557
615
  var flicking = _this._flicking;
616
+ var index = flicking.animating ? _this._nextIndex : flicking.index;
617
+ var currentPanel = flicking.animating ? flicking.panels[_this._nextIndex] : flicking.currentPanel;
558
618
  var camera = flicking.camera;
559
619
  var anchorPoints = camera.anchorPoints;
560
- if (flicking.animating || anchorPoints.length <= 0) return;
620
+ if (flicking.animating && !_this.interruptable || anchorPoints.length <= 0) return;
621
+
622
+ if (flicking.animating) {
623
+ flicking.stopAnimation();
624
+ }
625
+
561
626
  var lastAnchor = anchorPoints[anchorPoints.length - 1];
562
627
  var moveCount = _this._moveCount;
563
628
 
@@ -565,17 +630,17 @@ version: 4.7.0
565
630
  flicking.control.moveToPosition(camera.position + camera.size, flicking.duration).catch(_this._onCatch);
566
631
  } else {
567
632
  if (flicking.circularEnabled) {
568
- var targetPanel = flicking.currentPanel;
633
+ var targetPanel = currentPanel;
569
634
 
570
635
  for (var i = 0; i < moveCount; i++) {
571
636
  targetPanel = targetPanel.next();
572
637
  }
573
638
 
574
639
  targetPanel.focus().catch(_this._onCatch);
575
- } else if (flicking.index < lastAnchor.panel.index) {
576
- flicking.moveTo(Math.min(flicking.index + moveCount, lastAnchor.panel.index)).catch(_this._onCatch);
640
+ } else if (index < lastAnchor.panel.index) {
641
+ flicking.moveTo(Math.min(index + moveCount, lastAnchor.panel.index)).catch(_this._onCatch);
577
642
  } else if (camera.position > camera.range.min) {
578
- flicking.moveTo(flicking.index).catch(_this._onCatch);
643
+ flicking.moveTo(index).catch(_this._onCatch);
579
644
  }
580
645
  }
581
646
  };
@@ -592,6 +657,10 @@ version: 4.7.0
592
657
  }
593
658
  };
594
659
 
660
+ this._onWillChange = function (e) {
661
+ _this._nextIndex = e.index;
662
+ };
663
+
595
664
  this._onCatch = function (err) {
596
665
  if (err instanceof flicking.FlickingError) return;
597
666
  throw err;
@@ -603,6 +672,7 @@ version: 4.7.0
603
672
  this._disabledClass = disabledClass;
604
673
  this._moveCount = moveCount;
605
674
  this._moveByViewportSize = moveByViewportSize;
675
+ this._interruptable = interruptable;
606
676
  }
607
677
 
608
678
  var __proto = Arrow.prototype;
@@ -680,6 +750,16 @@ version: 4.7.0
680
750
  enumerable: false,
681
751
  configurable: true
682
752
  });
753
+ Object.defineProperty(__proto, "interruptable", {
754
+ get: function () {
755
+ return this._interruptable;
756
+ },
757
+ set: function (val) {
758
+ this._interruptable = val;
759
+ },
760
+ enumerable: false,
761
+ configurable: true
762
+ });
683
763
 
684
764
  __proto.init = function (flicking$1) {
685
765
  var _this = this;
@@ -690,6 +770,7 @@ version: 4.7.0
690
770
 
691
771
  this._flicking = flicking$1;
692
772
  flicking$1.on(flicking.EVENTS.MOVE, this._onAnimation);
773
+ flicking$1.on(flicking.EVENTS.WILL_CHANGE, this._onWillChange);
693
774
  var parentEl = this._parentEl ? this._parentEl : flicking$1.element;
694
775
  var prevEl = getElement(this._prevElSelector, parentEl, "Arrow");
695
776
  var nextEl = getElement(this._nextElSelector, parentEl, "Arrow");
@@ -718,6 +799,7 @@ version: 4.7.0
718
799
  }
719
800
 
720
801
  flicking$1.off(flicking.EVENTS.MOVE, this._onAnimation);
802
+ flicking$1.off(flicking.EVENTS.WILL_CHANGE, this._onWillChange);
721
803
  var prevEl = this._prevEl;
722
804
  var nextEl = this._nextEl;
723
805
  [BROWSER.MOUSE_DOWN, BROWSER.TOUCH_START].forEach(function (evt) {
@@ -758,10 +840,10 @@ version: 4.7.0
758
840
  return Arrow;
759
841
  }();
760
842
 
761
- /**
762
- * Plugin for synchronizing multiple flickings
763
- * @ko 다양한 형태로 Flicking들이 같이 움직이게 할 수 있습니다.
764
- * @memberof Flicking.Plugins
843
+ /**
844
+ * Plugin for synchronizing multiple flickings
845
+ * @ko 다양한 형태로 Flicking들이 같이 움직이게 할 수 있습니다.
846
+ * @memberof Flicking.Plugins
765
847
  */
766
848
 
767
849
  var Sync =
@@ -1008,24 +1090,24 @@ version: 4.7.0
1008
1090
  }();
1009
1091
 
1010
1092
  /* eslint-disable no-underscore-dangle */
1011
- /**
1012
- * You can apply perspective effect while panel is moving.
1013
- * @ko 패널들을 움직이면서 입체감을 부여할 수 있습니다.
1014
- * @memberof Flicking.Plugins
1093
+ /**
1094
+ * You can apply perspective effect while panel is moving.
1095
+ * @ko 패널들을 움직이면서 입체감을 부여할 수 있습니다.
1096
+ * @memberof Flicking.Plugins
1015
1097
  */
1016
1098
 
1017
1099
  var Perspective =
1018
1100
  /*#__PURE__*/
1019
1101
  function () {
1020
- /**
1021
- * @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>
1022
- * @param - Effect amplication scale.<ko>효과 증폭도</ko>
1023
- * @param - Effect amplication rotate.<ko>회전 증폭도</ko>
1024
- * @param - The value of perspective CSS property. <ko>css perspective 속성 값</ko>
1025
- * @example
1026
- * ```ts
1027
- * flicking.addPlugins(new Perspective({ selector: "p", scale: 1, rotate: 1, perspective = 1000 }));
1028
- * ```
1102
+ /**
1103
+ * @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>
1104
+ * @param - Effect amplication scale.<ko>효과 증폭도</ko>
1105
+ * @param - Effect amplication rotate.<ko>회전 증폭도</ko>
1106
+ * @param - The value of perspective CSS property. <ko>css perspective 속성 값</ko>
1107
+ * @example
1108
+ * ```ts
1109
+ * flicking.addPlugins(new Perspective({ selector: "p", scale: 1, rotate: 1, perspective = 1000 }));
1110
+ * ```
1029
1111
  */
1030
1112
  function Perspective(_a) {
1031
1113
  var _this = this;
@@ -1562,8 +1644,8 @@ version: 4.7.0
1562
1644
  return ScrollBulletRenderer;
1563
1645
  }(Renderer);
1564
1646
 
1565
- /**
1566
- * @memberof Flicking.Plugins
1647
+ /**
1648
+ * @memberof Flicking.Plugins
1567
1649
  */
1568
1650
 
1569
1651
  var Pagination =
@@ -1823,8 +1905,8 @@ version: 4.7.0
1823
1905
  return Pagination;
1824
1906
  }();
1825
1907
 
1826
- /**
1827
- * @namespace Flicking
1908
+ /**
1909
+ * @namespace Flicking
1828
1910
  */
1829
1911
 
1830
1912
  exports.ARROW = ARROW;