@egjs/flicking-plugins 4.7.1 → 4.8.0-beta.1

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,9 +1,9 @@
1
- import Renderer from "./Renderer";
2
- declare class FractionRenderer extends Renderer {
3
- private _prevIndex;
4
- private _prevTotal;
5
- destroy(): void;
6
- render(): void;
7
- update(index: number): void;
8
- }
9
- export default FractionRenderer;
1
+ import Renderer from "./Renderer";
2
+ declare class FractionRenderer extends Renderer {
3
+ private _prevIndex;
4
+ private _prevTotal;
5
+ destroy(): void;
6
+ render(): void;
7
+ update(index: number): void;
8
+ }
9
+ export default FractionRenderer;
@@ -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.1
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,27 @@ 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 {boolean} options.stopOnInit Whether to stop when mouse hover upon the element.<ko>엘리먼트에 마우스를 올렸을 AutoPlay를 정지할지 여부</ko>
231
+ * @param {number} options.delayAfterHover If stopOnHover is true, the amount of time to wait before moving on to the next panel when mouse leaves the element.<ko>stopOnHover를 사용한다면 마우스가 엘리먼트로부터 나간 뒤 다음 패널로 움직이기까지 대기 시간</ko>
232
+ * @example
233
+ * ```ts
234
+ * flicking.addPlugins(new AutoPlay({ duration: 2000, direction: "NEXT" }));
235
+ * ```
235
236
  */
236
237
  function AutoPlay(_a) {
237
238
  var _this = this;
@@ -245,6 +246,8 @@ function () {
245
246
  direction = _e === void 0 ? DIRECTION.NEXT : _e,
246
247
  _f = _b.stopOnHover,
247
248
  stopOnHover = _f === void 0 ? false : _f,
249
+ _g = _b.stopOnInit,
250
+ stopOnInit = _g === void 0 ? false : _g,
248
251
  delayAfterHover = _b.delayAfterHover;
249
252
  /* Internal Values */
250
253
 
@@ -279,6 +282,7 @@ function () {
279
282
  this._animationDuration = animationDuration;
280
283
  this._direction = direction;
281
284
  this._stopOnHover = stopOnHover;
285
+ this._stopOnInit = stopOnInit;
282
286
  this._delayAfterHover = delayAfterHover !== null && delayAfterHover !== void 0 ? delayAfterHover : duration;
283
287
  }
284
288
 
@@ -323,6 +327,16 @@ function () {
323
327
  enumerable: false,
324
328
  configurable: true
325
329
  });
330
+ Object.defineProperty(__proto, "stopOnInit", {
331
+ get: function () {
332
+ return this._stopOnInit;
333
+ },
334
+ set: function (val) {
335
+ this._stopOnInit = val;
336
+ },
337
+ enumerable: false,
338
+ configurable: true
339
+ });
326
340
  Object.defineProperty(__proto, "delayAfterHover", {
327
341
  get: function () {
328
342
  return this._delayAfterHover;
@@ -357,7 +371,9 @@ function () {
357
371
  targetEl.addEventListener("mouseleave", this._onMouseLeave, false);
358
372
  }
359
373
 
360
- this.play();
374
+ if (!this._stopOnInit) {
375
+ this.play();
376
+ }
361
377
  };
362
378
 
363
379
  __proto.destroy = function () {
@@ -537,10 +553,10 @@ var getElement = function (selector, parent, pluginName) {
537
553
  return el;
538
554
  };
539
555
 
540
- /**
541
- * A plugin to easily create prev/right arrow button of Flicking
542
- * @ko 이전/다음 버튼을 쉽게 만들 수 있는 플러그인
543
- * @memberof Flicking.Plugins
556
+ /**
557
+ * A plugin to easily create prev/right arrow button of Flicking
558
+ * @ko 이전/다음 버튼을 쉽게 만들 수 있는 플러그인
559
+ * @memberof Flicking.Plugins
544
560
  */
545
561
 
546
562
  var Arrow =
@@ -561,7 +577,9 @@ function () {
561
577
  _g = _b.moveCount,
562
578
  moveCount = _g === void 0 ? 1 : _g,
563
579
  _h = _b.moveByViewportSize,
564
- moveByViewportSize = _h === void 0 ? false : _h;
580
+ moveByViewportSize = _h === void 0 ? false : _h,
581
+ _j = _b.interruptable,
582
+ interruptable = _j === void 0 ? false : _j;
565
583
  /* Internal Values */
566
584
 
567
585
 
@@ -573,9 +591,16 @@ function () {
573
591
 
574
592
  this._onPrevClick = function () {
575
593
  var flicking = _this._flicking;
594
+ var index = flicking.animating ? _this._nextIndex : flicking.index;
595
+ var currentPanel = flicking.animating ? flicking.panels[_this._nextIndex] : flicking.currentPanel;
576
596
  var camera = flicking.camera;
577
597
  var anchorPoints = camera.anchorPoints;
578
- if (flicking.animating || anchorPoints.length <= 0) return;
598
+ if (flicking.animating && !_this.interruptable || anchorPoints.length <= 0) return;
599
+
600
+ if (flicking.animating) {
601
+ flicking.stopAnimation();
602
+ }
603
+
579
604
  var firstAnchor = anchorPoints[0];
580
605
  var moveCount = _this._moveCount;
581
606
 
@@ -583,26 +608,33 @@ function () {
583
608
  flicking.control.moveToPosition(camera.position - camera.size, flicking.duration).catch(_this._onCatch);
584
609
  } else {
585
610
  if (flicking.circularEnabled) {
586
- var targetPanel = flicking.currentPanel;
611
+ var targetPanel = currentPanel;
587
612
 
588
613
  for (var i = 0; i < moveCount; i++) {
589
614
  targetPanel = targetPanel.prev();
590
615
  }
591
616
 
592
617
  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);
618
+ } else if (index > firstAnchor.panel.index) {
619
+ flicking.moveTo(Math.max(index - moveCount, firstAnchor.panel.index)).catch(_this._onCatch);
595
620
  } else if (camera.position > camera.range.min) {
596
- flicking.moveTo(flicking.index).catch(_this._onCatch);
621
+ flicking.moveTo(index).catch(_this._onCatch);
597
622
  }
598
623
  }
599
624
  };
600
625
 
601
626
  this._onNextClick = function () {
602
627
  var flicking = _this._flicking;
628
+ var index = flicking.animating ? _this._nextIndex : flicking.index;
629
+ var currentPanel = flicking.animating ? flicking.panels[_this._nextIndex] : flicking.currentPanel;
603
630
  var camera = flicking.camera;
604
631
  var anchorPoints = camera.anchorPoints;
605
- if (flicking.animating || anchorPoints.length <= 0) return;
632
+ if (flicking.animating && !_this.interruptable || anchorPoints.length <= 0) return;
633
+
634
+ if (flicking.animating) {
635
+ flicking.stopAnimation();
636
+ }
637
+
606
638
  var lastAnchor = anchorPoints[anchorPoints.length - 1];
607
639
  var moveCount = _this._moveCount;
608
640
 
@@ -610,17 +642,17 @@ function () {
610
642
  flicking.control.moveToPosition(camera.position + camera.size, flicking.duration).catch(_this._onCatch);
611
643
  } else {
612
644
  if (flicking.circularEnabled) {
613
- var targetPanel = flicking.currentPanel;
645
+ var targetPanel = currentPanel;
614
646
 
615
647
  for (var i = 0; i < moveCount; i++) {
616
648
  targetPanel = targetPanel.next();
617
649
  }
618
650
 
619
651
  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);
652
+ } else if (index < lastAnchor.panel.index) {
653
+ flicking.moveTo(Math.min(index + moveCount, lastAnchor.panel.index)).catch(_this._onCatch);
622
654
  } else if (camera.position > camera.range.min) {
623
- flicking.moveTo(flicking.index).catch(_this._onCatch);
655
+ flicking.moveTo(index).catch(_this._onCatch);
624
656
  }
625
657
  }
626
658
  };
@@ -637,6 +669,10 @@ function () {
637
669
  }
638
670
  };
639
671
 
672
+ this._onWillChange = function (e) {
673
+ _this._nextIndex = e.index;
674
+ };
675
+
640
676
  this._onCatch = function (err) {
641
677
  if (err instanceof FlickingError) return;
642
678
  throw err;
@@ -648,6 +684,7 @@ function () {
648
684
  this._disabledClass = disabledClass;
649
685
  this._moveCount = moveCount;
650
686
  this._moveByViewportSize = moveByViewportSize;
687
+ this._interruptable = interruptable;
651
688
  }
652
689
 
653
690
  var __proto = Arrow.prototype;
@@ -725,6 +762,16 @@ function () {
725
762
  enumerable: false,
726
763
  configurable: true
727
764
  });
765
+ Object.defineProperty(__proto, "interruptable", {
766
+ get: function () {
767
+ return this._interruptable;
768
+ },
769
+ set: function (val) {
770
+ this._interruptable = val;
771
+ },
772
+ enumerable: false,
773
+ configurable: true
774
+ });
728
775
 
729
776
  __proto.init = function (flicking) {
730
777
  var _this = this;
@@ -735,6 +782,7 @@ function () {
735
782
 
736
783
  this._flicking = flicking;
737
784
  flicking.on(EVENTS.MOVE, this._onAnimation);
785
+ flicking.on(EVENTS.WILL_CHANGE, this._onWillChange);
738
786
  var parentEl = this._parentEl ? this._parentEl : flicking.element;
739
787
  var prevEl = getElement(this._prevElSelector, parentEl, "Arrow");
740
788
  var nextEl = getElement(this._nextElSelector, parentEl, "Arrow");
@@ -763,6 +811,7 @@ function () {
763
811
  }
764
812
 
765
813
  flicking.off(EVENTS.MOVE, this._onAnimation);
814
+ flicking.off(EVENTS.WILL_CHANGE, this._onWillChange);
766
815
  var prevEl = this._prevEl;
767
816
  var nextEl = this._nextEl;
768
817
  [BROWSER.MOUSE_DOWN, BROWSER.TOUCH_START].forEach(function (evt) {
@@ -803,10 +852,10 @@ function () {
803
852
  return Arrow;
804
853
  }();
805
854
 
806
- /**
807
- * Plugin for synchronizing multiple flickings
808
- * @ko 다양한 형태로 Flicking들이 같이 움직이게 할 수 있습니다.
809
- * @memberof Flicking.Plugins
855
+ /**
856
+ * Plugin for synchronizing multiple flickings
857
+ * @ko 다양한 형태로 Flicking들이 같이 움직이게 할 수 있습니다.
858
+ * @memberof Flicking.Plugins
810
859
  */
811
860
 
812
861
  var Sync =
@@ -1053,24 +1102,24 @@ function () {
1053
1102
  }();
1054
1103
 
1055
1104
  /* eslint-disable no-underscore-dangle */
1056
- /**
1057
- * You can apply perspective effect while panel is moving.
1058
- * @ko 패널들을 움직이면서 입체감을 부여할 수 있습니다.
1059
- * @memberof Flicking.Plugins
1105
+ /**
1106
+ * You can apply perspective effect while panel is moving.
1107
+ * @ko 패널들을 움직이면서 입체감을 부여할 수 있습니다.
1108
+ * @memberof Flicking.Plugins
1060
1109
  */
1061
1110
 
1062
1111
  var Perspective =
1063
1112
  /*#__PURE__*/
1064
1113
  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
- * ```
1114
+ /**
1115
+ * @param - The selector of the element to which the perspective effect is to be applied. If the selector is blank, it applies to panel element. <ko>입체 효과를 적용할 대상의 선택자. 선택자가 공백이면 패널 엘리먼트에 적용된다.</ko>
1116
+ * @param - Effect amplication scale.<ko>효과 증폭도</ko>
1117
+ * @param - Effect amplication rotate.<ko>회전 증폭도</ko>
1118
+ * @param - The value of perspective CSS property. <ko>css perspective 속성 값</ko>
1119
+ * @example
1120
+ * ```ts
1121
+ * flicking.addPlugins(new Perspective({ selector: "p", scale: 1, rotate: 1, perspective = 1000 }));
1122
+ * ```
1074
1123
  */
1075
1124
  function Perspective(_a) {
1076
1125
  var _this = this;
@@ -1607,8 +1656,8 @@ function (_super) {
1607
1656
  return ScrollBulletRenderer;
1608
1657
  }(Renderer);
1609
1658
 
1610
- /**
1611
- * @memberof Flicking.Plugins
1659
+ /**
1660
+ * @memberof Flicking.Plugins
1612
1661
  */
1613
1662
 
1614
1663
  var Pagination =
@@ -1868,8 +1917,8 @@ function () {
1868
1917
  return Pagination;
1869
1918
  }();
1870
1919
 
1871
- /**
1872
- * @namespace Flicking
1920
+ /**
1921
+ * @namespace Flicking
1873
1922
  */
1874
1923
 
1875
1924
  export { ARROW, Arrow, AutoPlay, Fade, PAGINATION, Pagination, Parallax, Perspective, SYNC, Sync };