@egjs/flicking 4.12.0-beta.0 → 4.12.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.
@@ -4,7 +4,7 @@ name: @egjs/flicking
4
4
  license: MIT
5
5
  author: NAVER Corp.
6
6
  repository: https://github.com/naver/egjs-flicking
7
- version: 4.12.0-beta.0
7
+ version: 4.12.0-beta.1
8
8
  */
9
9
  (function (global, factory) {
10
10
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -820,6 +820,17 @@ version: 4.12.0-beta.0
820
820
  LTR: "ltr",
821
821
  RTL: "rtl"
822
822
  };
823
+ /**
824
+ * An object that contains the direction that {@link Flicking} is moving
825
+ * @ko {@link Flicking}이 움직이는 방향을 담고 있는 객체
826
+ * @type {object}
827
+ * @property {"horizontal"} HORIZONTAL horizontal<ko>수평 방향</ko>
828
+ * @property {"vertical"} VERTICAL vertical<ko>수직 방향</ko>
829
+ */
830
+ var MOVE_DIRECTION = {
831
+ HORIZONTAL: "horizontal",
832
+ VERTICAL: "vertical"
833
+ };
823
834
 
824
835
  var Constants = {
825
836
  __proto__: null,
@@ -830,6 +841,7 @@ version: 4.12.0-beta.0
830
841
  CLASS: CLASS,
831
842
  CIRCULAR_FALLBACK: CIRCULAR_FALLBACK,
832
843
  ORDER: ORDER,
844
+ MOVE_DIRECTION: MOVE_DIRECTION,
833
845
  ERROR_CODE: CODE
834
846
  };
835
847
 
@@ -12983,10 +12995,189 @@ version: 4.12.0-beta.0
12983
12995
  * Flicking.VERSION; // ex) 4.0.0
12984
12996
  * ```
12985
12997
  */
12986
- Flicking.VERSION = "4.12.0-beta.0";
12998
+ Flicking.VERSION = "4.12.0-beta.1";
12987
12999
  return Flicking;
12988
13000
  }(Component);
12989
13001
 
13002
+ /*
13003
+ * Copyright (c) 2015 NAVER Corp.
13004
+ * egjs projects are licensed under the MIT license
13005
+ */
13006
+ /**
13007
+ * @extends Component
13008
+ * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
13009
+ * @requires {@link https://github.com/naver/egjs-component|@egjs/component}
13010
+ * @requires {@link https://github.com/naver/egjs-axes|@egjs/axes}
13011
+ */
13012
+ var CrossFlicking = /*#__PURE__*/function (_super) {
13013
+ __extends$3(CrossFlicking, _super);
13014
+ // Options Setter
13015
+ // UI / LAYOUT
13016
+ // public set align(val: FlickingOptions["align"]) {
13017
+ // this._align = val;
13018
+ // }
13019
+ function CrossFlicking(root, _a) {
13020
+ var _b = (_a === void 0 ? {} : _a).verticalOptions,
13021
+ verticalOptions = _b === void 0 ? undefined : _b;
13022
+ var _this = _super.call(this, root) || this;
13023
+ _this._onHorizontalHoldStart = function () {
13024
+ _this.dragThreshold = 10;
13025
+ _this._moveDirection = null;
13026
+ };
13027
+ _this._onHorizontalMove = function (e) {
13028
+ if (e.isTrusted && !_this._moveDirection) {
13029
+ _this._verticalFlicking.forEach(function (child) {
13030
+ child.dragThreshold = Infinity;
13031
+ });
13032
+ _this._moveDirection = MOVE_DIRECTION.HORIZONTAL;
13033
+ }
13034
+ };
13035
+ _this._onHorizontalMoveEnd = function (e) {
13036
+ var visiblePanels = _this.visiblePanels;
13037
+ _this._verticalFlicking.forEach(function (child) {
13038
+ child.dragThreshold = 10;
13039
+ });
13040
+ _this._moveDirection = null;
13041
+ if (visiblePanels.length > 1) {
13042
+ _this._nextIndex = e.direction === "NEXT" ? visiblePanels[1].index : visiblePanels[0].index;
13043
+ } else {
13044
+ _this._nextIndex = visiblePanels[0].index;
13045
+ }
13046
+ _this._verticalFlicking.forEach(function (child, i) {
13047
+ if (_this._nextIndex !== i) {
13048
+ var _a = _this._verticalState[i],
13049
+ start = _a.start,
13050
+ end = _a.end;
13051
+ if (child.index < start) {
13052
+ child.stopAnimation();
13053
+ void child.moveTo(start, 0);
13054
+ } else if (child.index > end) {
13055
+ child.stopAnimation();
13056
+ void child.moveTo(end, 0);
13057
+ }
13058
+ }
13059
+ });
13060
+ if (e.isTrusted) {
13061
+ _this._syncToCategory(_this._verticalFlicking[_this._nextIndex].index, _this._nextIndex);
13062
+ }
13063
+ };
13064
+ _this._onVerticalHoldStart = function () {
13065
+ _this._verticalFlicking.forEach(function (child) {
13066
+ child.dragThreshold = 10;
13067
+ });
13068
+ _this._moveDirection = null;
13069
+ };
13070
+ _this._onVerticalMove = function (e) {
13071
+ if (e.isTrusted && !_this._moveDirection) {
13072
+ _this.dragThreshold = Infinity;
13073
+ _this._moveDirection = MOVE_DIRECTION.VERTICAL;
13074
+ }
13075
+ };
13076
+ _this._onVerticalMoveEnd = function () {
13077
+ _this.dragThreshold = 10;
13078
+ _this._moveDirection = null;
13079
+ };
13080
+ _this._onVerticalChanged = function (e) {
13081
+ // this.visiblePanels.length 가 2보다 크다면 가로 방향 Flicking이 조작 중이라는 것을 의미합니다.
13082
+ // 이 경우 가로 방향 Flicking의 이동이 완전히 끝난 뒤 _onHorizontalMoveEnd 에서 syncToCategory할 것이므로 여기서는 하지 않습니다.
13083
+ if (_this.visiblePanels.length < 2 && _this._verticalFlicking[_this.index] === e.currentTarget) {
13084
+ _this._syncToCategory(e.index, _this.index);
13085
+ }
13086
+ };
13087
+ // Internal states
13088
+ _this._verticalState = [];
13089
+ _this._moveDirection = null;
13090
+ _this._nextIndex = 0;
13091
+ // Bind options
13092
+ _this._verticalOptions = verticalOptions;
13093
+ return _this;
13094
+ // Create core components
13095
+ // this._viewport = new Viewport(this, getElement(root));
13096
+ }
13097
+ var __proto = CrossFlicking.prototype;
13098
+ Object.defineProperty(__proto, "verticalOptions", {
13099
+ // Components
13100
+ /**
13101
+ * Change active panel index on mouse/touch hold while animating.
13102
+ * `index` of the `willChange`/`willRestore` event will be used as new index.
13103
+ * @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
13104
+ * `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
13105
+ * @type {FlickingOptions}
13106
+ * @default undefined
13107
+ * @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
13108
+ */
13109
+ get: function () {
13110
+ return this._verticalOptions;
13111
+ },
13112
+ enumerable: false,
13113
+ configurable: true
13114
+ });
13115
+ /**
13116
+ * Initialize Flicking and move to the default index
13117
+ * This is automatically called on Flicking's constructor when `autoInit` is true(default)
13118
+ * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
13119
+ * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
13120
+ * @fires Flicking#ready
13121
+ * @return {Promise<void>}
13122
+ */
13123
+ __proto.init = function () {
13124
+ var _this = this;
13125
+ return _super.prototype.init.call(this).then(function () {
13126
+ // data-index로 분류하기 전에 임시로 모든 children에 대해 vertical flicking으로 해보자.
13127
+ // camera.children들에 대해 갯수 세기
13128
+ var verticalPanels = "";
13129
+ _this._verticalState = _this.camera.children.reduce(function (state, child) {
13130
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
13131
+ verticalPanels += child.children[0].innerHTML;
13132
+ return __spread$1(state, [{
13133
+ start: start,
13134
+ end: start + child.children[0].children.length - 1,
13135
+ element: child
13136
+ }]);
13137
+ }, []);
13138
+ _this.camera.children.forEach(function (child) {
13139
+ child.children[0].innerHTML = verticalPanels;
13140
+ });
13141
+ _this._verticalFlicking = _this.camera.children.map(function (child, i) {
13142
+ return new Flicking(child, __assign$2(__assign$2({}, _this.verticalOptions), {
13143
+ horizontal: false,
13144
+ panelsPerView: 1,
13145
+ defaultIndex: _this._verticalState[i].start
13146
+ }));
13147
+ });
13148
+ _this.on(EVENTS.HOLD_START, _this._onHorizontalHoldStart);
13149
+ _this.on(EVENTS.MOVE, _this._onHorizontalMove);
13150
+ _this.on(EVENTS.MOVE_END, _this._onHorizontalMoveEnd);
13151
+ _this._verticalFlicking.forEach(function (child) {
13152
+ child.on(EVENTS.HOLD_START, _this._onVerticalHoldStart);
13153
+ child.on(EVENTS.MOVE, _this._onVerticalMove);
13154
+ child.on(EVENTS.MOVE_END, _this._onVerticalMoveEnd);
13155
+ child.on(EVENTS.CHANGED, _this._onVerticalChanged);
13156
+ });
13157
+ });
13158
+ };
13159
+ __proto._syncToCategory = function (index, outerIndex) {
13160
+ var _this = this;
13161
+ this.stopAnimation();
13162
+ this._verticalFlicking.forEach(function (child, i) {
13163
+ var _a = _this._verticalState[i],
13164
+ start = _a.start,
13165
+ end = _a.end;
13166
+ if (start <= index && end >= index && outerIndex !== i) {
13167
+ child.stopAnimation();
13168
+ void child.moveTo(index, 0);
13169
+ void _this.moveTo(i, 0);
13170
+ }
13171
+ });
13172
+ };
13173
+ return CrossFlicking;
13174
+ }(Flicking);
13175
+
13176
+ var CrossFlicking$1 = {
13177
+ __proto__: null,
13178
+ CrossFlicking: CrossFlicking
13179
+ };
13180
+
12990
13181
  /*
12991
13182
  * Copyright (c) 2015 NAVER Corp.
12992
13183
  * egjs projects are licensed under the MIT license
@@ -13232,6 +13423,7 @@ version: 4.12.0-beta.0
13232
13423
  merge(Flicking, Constants);
13233
13424
  merge(Flicking, CFC);
13234
13425
  merge(Flicking, Utils);
13426
+ merge(Flicking, CrossFlicking$1);
13235
13427
 
13236
13428
  return Flicking;
13237
13429