@egjs/flicking-plugins 4.7.1 → 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.
@@ -1,19 +1,19 @@
1
- import Flicking from "@egjs/flicking";
2
- import Pagination from "../Pagination";
3
- export interface RendererOptions {
4
- flicking: Flicking;
5
- pagination: Pagination;
6
- wrapper: HTMLElement;
7
- }
8
- declare abstract class Renderer {
9
- protected _flicking: Flicking;
10
- protected _pagination: Pagination;
11
- protected _wrapper: HTMLElement;
12
- constructor({ flicking, pagination, wrapper }: RendererOptions);
13
- abstract destroy(): void;
14
- abstract render(): void;
15
- abstract update(index: number): void;
16
- protected _createBulletFromString(html: string, index: number): HTMLElement;
17
- protected _addBulletEvents(bullet: HTMLElement, index: number): void;
18
- }
19
- export default Renderer;
1
+ import Flicking from "@egjs/flicking";
2
+ import Pagination from "../Pagination";
3
+ export interface RendererOptions {
4
+ flicking: Flicking;
5
+ pagination: Pagination;
6
+ wrapper: HTMLElement;
7
+ }
8
+ declare abstract class Renderer {
9
+ protected _flicking: Flicking;
10
+ protected _pagination: Pagination;
11
+ protected _wrapper: HTMLElement;
12
+ constructor({ flicking, pagination, wrapper }: RendererOptions);
13
+ abstract destroy(): void;
14
+ abstract render(): void;
15
+ abstract update(index: number): void;
16
+ protected _createBulletFromString(html: string, index: number): HTMLElement;
17
+ protected _addBulletEvents(bullet: HTMLElement, index: number): void;
18
+ }
19
+ export default Renderer;
@@ -1,12 +1,12 @@
1
- import Renderer from "./Renderer";
2
- declare class ScrollBulletRenderer extends Renderer {
3
- private _bullets;
4
- private _bulletSize;
5
- private _previousIndex;
6
- private _sliderIndex;
7
- destroy(): void;
8
- render(): void;
9
- update(index: number): void;
10
- moveTo: (index: number) => void;
11
- }
12
- export default ScrollBulletRenderer;
1
+ import Renderer from "./Renderer";
2
+ declare class ScrollBulletRenderer extends Renderer {
3
+ private _bullets;
4
+ private _bulletSize;
5
+ private _previousIndex;
6
+ private _sliderIndex;
7
+ destroy(): void;
8
+ render(): void;
9
+ update(index: number): void;
10
+ moveTo: (index: number) => void;
11
+ }
12
+ export default ScrollBulletRenderer;
@@ -1,9 +1,9 @@
1
- interface ScrollContext {
2
- total: number;
3
- prevIndex: number;
4
- sliderIndex: number;
5
- direction: "NEXT" | "PREV";
6
- bullets: HTMLElement[];
7
- moveTo: (index: number) => void;
8
- }
9
- export default ScrollContext;
1
+ interface ScrollContext {
2
+ total: number;
3
+ prevIndex: number;
4
+ sliderIndex: number;
5
+ direction: "NEXT" | "PREV";
6
+ bullets: HTMLElement[];
7
+ moveTo: (index: number) => void;
8
+ }
9
+ export default ScrollContext;
@@ -1,3 +1,3 @@
1
- export declare const addClass: (el: HTMLElement, className: string) => void;
2
- export declare const removeClass: (el: HTMLElement, className: string) => void;
3
- export declare const getElement: (selector: string, parent: HTMLElement, pluginName: string) => HTMLElement;
1
+ export declare const addClass: (el: HTMLElement, className: string) => void;
2
+ export declare const removeClass: (el: HTMLElement, className: string) => void;
3
+ export declare const getElement: (selector: string, parent: HTMLElement, pluginName: string) => HTMLElement;
@@ -4,26 +4,26 @@ 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.1
7
+ version: 4.8.0-beta.0
8
8
  */
9
9
  import { EVENTS, MOVE_TYPE, DIRECTION, FlickingError, clamp } from '@egjs/flicking';
10
10
 
11
- /**
12
- * You can apply parallax effect while panel is moving.
13
- * @ko 패널들을 움직이면서 parallax 효과를 부여할 수 있습니다.
14
- * @memberof Flicking.Plugins
11
+ /**
12
+ * You can apply parallax effect while panel is moving.
13
+ * @ko 패널들을 움직이면서 parallax 효과를 부여할 수 있습니다.
14
+ * @memberof Flicking.Plugins
15
15
  */
16
16
 
17
17
  var Parallax =
18
18
  /*#__PURE__*/
19
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
- * ```
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
27
  */
28
28
  function Parallax(selector, scale) {
29
29
  var _this = this;
@@ -110,22 +110,22 @@ function () {
110
110
  return Parallax;
111
111
  }();
112
112
 
113
- /**
114
- * You can apply fade in / out effect while panel is moving.
115
- * @ko 패널들을 움직이면서 fade in / out 효과를 부여할 수 있습니다.
116
- * @memberof Flicking.Plugins
113
+ /**
114
+ * You can apply fade in / out effect while panel is moving.
115
+ * @ko 패널들을 움직이면서 fade in / out 효과를 부여할 수 있습니다.
116
+ * @memberof Flicking.Plugins
117
117
  */
118
118
 
119
119
  var Fade =
120
120
  /*#__PURE__*/
121
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
- * ```
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
129
  */
130
130
  function Fade(selector, scale) {
131
131
  var _this = this;
@@ -212,26 +212,26 @@ function () {
212
212
  return Fade;
213
213
  }();
214
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
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
219
  */
220
220
 
221
221
  var AutoPlay =
222
222
  /*#__PURE__*/
223
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
- * ```
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
235
  */
236
236
  function AutoPlay(_a) {
237
237
  var _this = this;
@@ -537,10 +537,10 @@ var getElement = function (selector, parent, pluginName) {
537
537
  return el;
538
538
  };
539
539
 
540
- /**
541
- * A plugin to easily create prev/right arrow button of Flicking
542
- * @ko 이전/다음 버튼을 쉽게 만들 수 있는 플러그인
543
- * @memberof Flicking.Plugins
540
+ /**
541
+ * A plugin to easily create prev/right arrow button of Flicking
542
+ * @ko 이전/다음 버튼을 쉽게 만들 수 있는 플러그인
543
+ * @memberof Flicking.Plugins
544
544
  */
545
545
 
546
546
  var Arrow =
@@ -561,7 +561,9 @@ function () {
561
561
  _g = _b.moveCount,
562
562
  moveCount = _g === void 0 ? 1 : _g,
563
563
  _h = _b.moveByViewportSize,
564
- moveByViewportSize = _h === void 0 ? false : _h;
564
+ moveByViewportSize = _h === void 0 ? false : _h,
565
+ _j = _b.interruptable,
566
+ interruptable = _j === void 0 ? false : _j;
565
567
  /* Internal Values */
566
568
 
567
569
 
@@ -573,9 +575,16 @@ function () {
573
575
 
574
576
  this._onPrevClick = function () {
575
577
  var flicking = _this._flicking;
578
+ var index = flicking.animating ? _this._nextIndex : flicking.index;
579
+ var currentPanel = flicking.animating ? flicking.panels[_this._nextIndex] : flicking.currentPanel;
576
580
  var camera = flicking.camera;
577
581
  var anchorPoints = camera.anchorPoints;
578
- if (flicking.animating || anchorPoints.length <= 0) return;
582
+ if (flicking.animating && !_this.interruptable || anchorPoints.length <= 0) return;
583
+
584
+ if (flicking.animating) {
585
+ flicking.stopAnimation();
586
+ }
587
+
579
588
  var firstAnchor = anchorPoints[0];
580
589
  var moveCount = _this._moveCount;
581
590
 
@@ -583,26 +592,33 @@ function () {
583
592
  flicking.control.moveToPosition(camera.position - camera.size, flicking.duration).catch(_this._onCatch);
584
593
  } else {
585
594
  if (flicking.circularEnabled) {
586
- var targetPanel = flicking.currentPanel;
595
+ var targetPanel = currentPanel;
587
596
 
588
597
  for (var i = 0; i < moveCount; i++) {
589
598
  targetPanel = targetPanel.prev();
590
599
  }
591
600
 
592
601
  targetPanel.focus().catch(_this._onCatch);
593
- } else if (flicking.index > firstAnchor.panel.index) {
594
- flicking.moveTo(Math.max(flicking.index - moveCount, firstAnchor.panel.index)).catch(_this._onCatch);
602
+ } else if (index > firstAnchor.panel.index) {
603
+ flicking.moveTo(Math.max(index - moveCount, firstAnchor.panel.index)).catch(_this._onCatch);
595
604
  } else if (camera.position > camera.range.min) {
596
- flicking.moveTo(flicking.index).catch(_this._onCatch);
605
+ flicking.moveTo(index).catch(_this._onCatch);
597
606
  }
598
607
  }
599
608
  };
600
609
 
601
610
  this._onNextClick = function () {
602
611
  var flicking = _this._flicking;
612
+ var index = flicking.animating ? _this._nextIndex : flicking.index;
613
+ var currentPanel = flicking.animating ? flicking.panels[_this._nextIndex] : flicking.currentPanel;
603
614
  var camera = flicking.camera;
604
615
  var anchorPoints = camera.anchorPoints;
605
- if (flicking.animating || anchorPoints.length <= 0) return;
616
+ if (flicking.animating && !_this.interruptable || anchorPoints.length <= 0) return;
617
+
618
+ if (flicking.animating) {
619
+ flicking.stopAnimation();
620
+ }
621
+
606
622
  var lastAnchor = anchorPoints[anchorPoints.length - 1];
607
623
  var moveCount = _this._moveCount;
608
624
 
@@ -610,17 +626,17 @@ function () {
610
626
  flicking.control.moveToPosition(camera.position + camera.size, flicking.duration).catch(_this._onCatch);
611
627
  } else {
612
628
  if (flicking.circularEnabled) {
613
- var targetPanel = flicking.currentPanel;
629
+ var targetPanel = currentPanel;
614
630
 
615
631
  for (var i = 0; i < moveCount; i++) {
616
632
  targetPanel = targetPanel.next();
617
633
  }
618
634
 
619
635
  targetPanel.focus().catch(_this._onCatch);
620
- } else if (flicking.index < lastAnchor.panel.index) {
621
- flicking.moveTo(Math.min(flicking.index + moveCount, lastAnchor.panel.index)).catch(_this._onCatch);
636
+ } else if (index < lastAnchor.panel.index) {
637
+ flicking.moveTo(Math.min(index + moveCount, lastAnchor.panel.index)).catch(_this._onCatch);
622
638
  } else if (camera.position > camera.range.min) {
623
- flicking.moveTo(flicking.index).catch(_this._onCatch);
639
+ flicking.moveTo(index).catch(_this._onCatch);
624
640
  }
625
641
  }
626
642
  };
@@ -637,6 +653,10 @@ function () {
637
653
  }
638
654
  };
639
655
 
656
+ this._onWillChange = function (e) {
657
+ _this._nextIndex = e.index;
658
+ };
659
+
640
660
  this._onCatch = function (err) {
641
661
  if (err instanceof FlickingError) return;
642
662
  throw err;
@@ -648,6 +668,7 @@ function () {
648
668
  this._disabledClass = disabledClass;
649
669
  this._moveCount = moveCount;
650
670
  this._moveByViewportSize = moveByViewportSize;
671
+ this._interruptable = interruptable;
651
672
  }
652
673
 
653
674
  var __proto = Arrow.prototype;
@@ -725,6 +746,16 @@ function () {
725
746
  enumerable: false,
726
747
  configurable: true
727
748
  });
749
+ Object.defineProperty(__proto, "interruptable", {
750
+ get: function () {
751
+ return this._interruptable;
752
+ },
753
+ set: function (val) {
754
+ this._interruptable = val;
755
+ },
756
+ enumerable: false,
757
+ configurable: true
758
+ });
728
759
 
729
760
  __proto.init = function (flicking) {
730
761
  var _this = this;
@@ -735,6 +766,7 @@ function () {
735
766
 
736
767
  this._flicking = flicking;
737
768
  flicking.on(EVENTS.MOVE, this._onAnimation);
769
+ flicking.on(EVENTS.WILL_CHANGE, this._onWillChange);
738
770
  var parentEl = this._parentEl ? this._parentEl : flicking.element;
739
771
  var prevEl = getElement(this._prevElSelector, parentEl, "Arrow");
740
772
  var nextEl = getElement(this._nextElSelector, parentEl, "Arrow");
@@ -763,6 +795,7 @@ function () {
763
795
  }
764
796
 
765
797
  flicking.off(EVENTS.MOVE, this._onAnimation);
798
+ flicking.off(EVENTS.WILL_CHANGE, this._onWillChange);
766
799
  var prevEl = this._prevEl;
767
800
  var nextEl = this._nextEl;
768
801
  [BROWSER.MOUSE_DOWN, BROWSER.TOUCH_START].forEach(function (evt) {
@@ -803,10 +836,10 @@ function () {
803
836
  return Arrow;
804
837
  }();
805
838
 
806
- /**
807
- * Plugin for synchronizing multiple flickings
808
- * @ko 다양한 형태로 Flicking들이 같이 움직이게 할 수 있습니다.
809
- * @memberof Flicking.Plugins
839
+ /**
840
+ * Plugin for synchronizing multiple flickings
841
+ * @ko 다양한 형태로 Flicking들이 같이 움직이게 할 수 있습니다.
842
+ * @memberof Flicking.Plugins
810
843
  */
811
844
 
812
845
  var Sync =
@@ -1053,24 +1086,24 @@ function () {
1053
1086
  }();
1054
1087
 
1055
1088
  /* eslint-disable no-underscore-dangle */
1056
- /**
1057
- * You can apply perspective effect while panel is moving.
1058
- * @ko 패널들을 움직이면서 입체감을 부여할 수 있습니다.
1059
- * @memberof Flicking.Plugins
1089
+ /**
1090
+ * You can apply perspective effect while panel is moving.
1091
+ * @ko 패널들을 움직이면서 입체감을 부여할 수 있습니다.
1092
+ * @memberof Flicking.Plugins
1060
1093
  */
1061
1094
 
1062
1095
  var Perspective =
1063
1096
  /*#__PURE__*/
1064
1097
  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
- * ```
1098
+ /**
1099
+ * @param - The selector of the element to which the perspective effect is to be applied. If the selector is blank, it applies to panel element. <ko>입체 효과를 적용할 대상의 선택자. 선택자가 공백이면 패널 엘리먼트에 적용된다.</ko>
1100
+ * @param - Effect amplication scale.<ko>효과 증폭도</ko>
1101
+ * @param - Effect amplication rotate.<ko>회전 증폭도</ko>
1102
+ * @param - The value of perspective CSS property. <ko>css perspective 속성 값</ko>
1103
+ * @example
1104
+ * ```ts
1105
+ * flicking.addPlugins(new Perspective({ selector: "p", scale: 1, rotate: 1, perspective = 1000 }));
1106
+ * ```
1074
1107
  */
1075
1108
  function Perspective(_a) {
1076
1109
  var _this = this;
@@ -1607,8 +1640,8 @@ function (_super) {
1607
1640
  return ScrollBulletRenderer;
1608
1641
  }(Renderer);
1609
1642
 
1610
- /**
1611
- * @memberof Flicking.Plugins
1643
+ /**
1644
+ * @memberof Flicking.Plugins
1612
1645
  */
1613
1646
 
1614
1647
  var Pagination =
@@ -1868,8 +1901,8 @@ function () {
1868
1901
  return Pagination;
1869
1902
  }();
1870
1903
 
1871
- /**
1872
- * @namespace Flicking
1904
+ /**
1905
+ * @namespace Flicking
1873
1906
  */
1874
1907
 
1875
1908
  export { ARROW, Arrow, AutoPlay, Fade, PAGINATION, Pagination, Parallax, Perspective, SYNC, Sync };