@egjs/flicking-plugins 4.2.3 → 4.3.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.
@@ -0,0 +1,28 @@
1
+ import Flicking, { Plugin } from "@egjs/flicking";
2
+ interface PerspectiveOptions {
3
+ selector: string;
4
+ scale: number;
5
+ rotate: number;
6
+ perspective: number;
7
+ }
8
+ declare class Perspective implements Plugin {
9
+ private _flicking;
10
+ private _selector;
11
+ private _scale;
12
+ private _rotate;
13
+ private _perspective;
14
+ get selector(): string;
15
+ get scale(): number;
16
+ get rotate(): number;
17
+ get perspective(): number;
18
+ set selector(val: string);
19
+ set scale(val: number);
20
+ set rotate(val: number);
21
+ set perspective(val: number);
22
+ constructor({ selector, scale, rotate, perspective }?: Partial<PerspectiveOptions>);
23
+ init(flicking: Flicking): void;
24
+ destroy(): void;
25
+ update: () => void;
26
+ private _onMove;
27
+ }
28
+ export default Perspective;
@@ -3,7 +3,8 @@ import Fade from "./Fade";
3
3
  import AutoPlay from "./AutoPlay";
4
4
  import Arrow from "./Arrow";
5
5
  import Sync, { SyncOptions, SychronizableFlickingOptions } from "./Sync";
6
+ import Perspective from "./Perspective";
6
7
  export * from "./pagination";
7
- export { Parallax, Fade, AutoPlay, Arrow, Sync };
8
+ export { Parallax, Fade, AutoPlay, Arrow, Sync, Perspective };
8
9
  export type { SyncOptions, SychronizableFlickingOptions };
9
10
  export * from "./const";
@@ -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.2.3
7
+ version: 4.3.0
8
8
  */
9
9
  import { EVENTS, DIRECTION, FlickingError, clamp } from '@egjs/flicking';
10
10
 
@@ -102,6 +102,8 @@ function () {
102
102
 
103
103
  this._flicking.off(EVENTS.MOVE, this._onMove);
104
104
 
105
+ this._flicking.off(EVENTS.AFTER_RESIZE, this.update);
106
+
105
107
  this._flicking = null;
106
108
  };
107
109
 
@@ -199,6 +201,8 @@ function () {
199
201
 
200
202
  this._flicking.off(EVENTS.MOVE, this._onMove);
201
203
 
204
+ this._flicking.off(EVENTS.AFTER_RESIZE, this.update);
205
+
202
206
  this._flicking = null;
203
207
  };
204
208
 
@@ -406,6 +410,8 @@ var SYNC = {
406
410
  };
407
411
 
408
412
  var addClass = function (el, className) {
413
+ if (!el) return;
414
+
409
415
  if (el.classList) {
410
416
  el.classList.add(className);
411
417
  } else {
@@ -417,6 +423,8 @@ var addClass = function (el, className) {
417
423
  }
418
424
  };
419
425
  var removeClass = function (el, className) {
426
+ if (!el) return;
427
+
420
428
  if (el.classList) {
421
429
  el.classList.remove(className);
422
430
  } else {
@@ -636,8 +644,12 @@ function () {
636
644
  var prevEl = getElement(this._prevElSelector, parentEl, "Arrow");
637
645
  var nextEl = getElement(this._nextElSelector, parentEl, "Arrow");
638
646
  [BROWSER.MOUSE_DOWN, BROWSER.TOUCH_START].forEach(function (evt) {
639
- prevEl.addEventListener(evt, _this._preventInputPropagation);
640
- nextEl.addEventListener(evt, _this._preventInputPropagation);
647
+ prevEl.addEventListener(evt, _this._preventInputPropagation, {
648
+ passive: true
649
+ });
650
+ nextEl.addEventListener(evt, _this._preventInputPropagation, {
651
+ passive: true
652
+ });
641
653
  });
642
654
  prevEl.addEventListener(BROWSER.CLICK, this._onPrevClick);
643
655
  nextEl.addEventListener(BROWSER.CLICK, this._onNextClick);
@@ -945,6 +957,141 @@ function () {
945
957
  return Sync;
946
958
  }();
947
959
 
960
+ /* eslint-disable no-underscore-dangle */
961
+ /**
962
+ * You can apply perspective effect while panel is moving.
963
+ * @ko 패널들을 움직이면서 입체감을 부여할 수 있습니다.
964
+ * @memberof Flicking.Plugins
965
+ */
966
+
967
+ var Perspective =
968
+ /*#__PURE__*/
969
+ function () {
970
+ /**
971
+ * @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>
972
+ * @param - Effect amplication scale.<ko>효과 증폭도</ko>
973
+ * @param - Effect amplication rotate.<ko>회전 증폭도</ko>
974
+ * @param - The value of perspective CSS property. <ko>css perspective 속성 값</ko>
975
+ * @example
976
+ * ```ts
977
+ * flicking.addPlugins(new Perspective({ selector: "p", scale: 1, rotate: 1, perspective = 1000 }));
978
+ * ```
979
+ */
980
+ function Perspective(_a) {
981
+ var _this = this;
982
+
983
+ var _b = _a === void 0 ? {} : _a,
984
+ _c = _b.selector,
985
+ selector = _c === void 0 ? "" : _c,
986
+ _d = _b.scale,
987
+ scale = _d === void 0 ? 1 : _d,
988
+ _e = _b.rotate,
989
+ rotate = _e === void 0 ? 1 : _e,
990
+ _f = _b.perspective,
991
+ perspective = _f === void 0 ? 1000 : _f;
992
+
993
+ this.update = function () {
994
+ _this._onMove();
995
+ };
996
+
997
+ this._onMove = function () {
998
+ var flicking = _this._flicking;
999
+ var selector = _this._selector;
1000
+ var scale = _this._scale;
1001
+ var rotate = _this._rotate;
1002
+ var perspective = _this._perspective;
1003
+ if (!flicking) return;
1004
+ var horizontal = flicking.horizontal;
1005
+ var panels = flicking.visiblePanels;
1006
+ panels.forEach(function (panel) {
1007
+ var progress = panel.outsetProgress;
1008
+ var el = panel.element;
1009
+ var target = selector ? el.querySelector(selector) : el;
1010
+ var panelScale = 1 / (Math.abs(progress * scale) + 1);
1011
+ var rotateDegree = progress > 0 ? Math.min(90, progress * 100 * rotate) : Math.max(-90, progress * 100 * rotate);
1012
+
1013
+ var _a = horizontal ? [0, rotateDegree] : [rotateDegree, 0],
1014
+ rotateX = _a[0],
1015
+ rotateY = _a[1];
1016
+
1017
+ target.style.transform = "perspective(" + perspective + "px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg) scale(" + panelScale + ")";
1018
+ });
1019
+ };
1020
+
1021
+ this._flicking = null;
1022
+ this._selector = selector;
1023
+ this._scale = scale;
1024
+ this._rotate = rotate;
1025
+ this._perspective = perspective;
1026
+ }
1027
+
1028
+ var __proto = Perspective.prototype;
1029
+ Object.defineProperty(__proto, "selector", {
1030
+ get: function () {
1031
+ return this._selector;
1032
+ },
1033
+ set: function (val) {
1034
+ this._selector = val;
1035
+ },
1036
+ enumerable: false,
1037
+ configurable: true
1038
+ });
1039
+ Object.defineProperty(__proto, "scale", {
1040
+ get: function () {
1041
+ return this._scale;
1042
+ },
1043
+ set: function (val) {
1044
+ this._scale = val;
1045
+ },
1046
+ enumerable: false,
1047
+ configurable: true
1048
+ });
1049
+ Object.defineProperty(__proto, "rotate", {
1050
+ get: function () {
1051
+ return this._rotate;
1052
+ },
1053
+ set: function (val) {
1054
+ this._rotate = val;
1055
+ },
1056
+ enumerable: false,
1057
+ configurable: true
1058
+ });
1059
+ Object.defineProperty(__proto, "perspective", {
1060
+ get: function () {
1061
+ return this._perspective;
1062
+ },
1063
+ set: function (val) {
1064
+ this._perspective = val;
1065
+ },
1066
+ enumerable: false,
1067
+ configurable: true
1068
+ });
1069
+
1070
+ __proto.init = function (flicking) {
1071
+ if (this._flicking) {
1072
+ this.destroy();
1073
+ }
1074
+
1075
+ this._flicking = flicking;
1076
+ flicking.on(EVENTS.MOVE, this._onMove);
1077
+ flicking.on(EVENTS.AFTER_RESIZE, this.update);
1078
+
1079
+ this._onMove();
1080
+ };
1081
+
1082
+ __proto.destroy = function () {
1083
+ if (!this._flicking) return;
1084
+
1085
+ this._flicking.off(EVENTS.MOVE, this._onMove);
1086
+
1087
+ this._flicking.off(EVENTS.AFTER_RESIZE, this.update);
1088
+
1089
+ this._flicking = null;
1090
+ };
1091
+
1092
+ return Perspective;
1093
+ }();
1094
+
948
1095
  /*! *****************************************************************************
949
1096
  Copyright (c) Microsoft Corporation.
950
1097
 
@@ -1048,6 +1195,8 @@ function (_super) {
1048
1195
  });
1049
1196
  bullet.addEventListener(BROWSER.TOUCH_START, function (e) {
1050
1197
  e.stopPropagation();
1198
+ }, {
1199
+ passive: true
1051
1200
  });
1052
1201
  bullet.addEventListener(BROWSER.CLICK, function () {
1053
1202
  flicking.moveTo(anchorPoint.panel.index).catch(function (err) {
@@ -1170,6 +1319,8 @@ function (_super) {
1170
1319
  });
1171
1320
  bullet.addEventListener(BROWSER.TOUCH_START, function (e) {
1172
1321
  e.stopPropagation();
1322
+ }, {
1323
+ passive: true
1173
1324
  });
1174
1325
  bullet.addEventListener(BROWSER.CLICK, function () {
1175
1326
  flicking.moveTo(anchorPoint.panel.index).catch(function (err) {
@@ -1497,5 +1648,5 @@ function () {
1497
1648
  * @namespace Flicking
1498
1649
  */
1499
1650
 
1500
- export { ARROW, Arrow, AutoPlay, Fade, PAGINATION, Pagination, Parallax, SYNC, Sync };
1651
+ export { ARROW, Arrow, AutoPlay, Fade, PAGINATION, Pagination, Parallax, Perspective, SYNC, Sync };
1501
1652
  //# sourceMappingURL=plugins.esm.js.map