@egjs/flicking 4.12.0-beta.7 → 4.12.0-beta.9

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.7
7
+ version: 4.12.0-beta.9
8
8
  */
9
9
  (function (global, factory) {
10
10
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -2899,7 +2899,7 @@ version: 4.12.0-beta.7
2899
2899
  * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
2900
2900
  * @private
2901
2901
  */
2902
- var requestAnimationFrame = function (fp) {
2902
+ var requestAnimationFrame$1 = function (fp) {
2903
2903
  return raf(fp);
2904
2904
  };
2905
2905
  /**
@@ -4447,7 +4447,7 @@ version: 4.12.0-beta.7
4447
4447
  } else if (isCanceled) {
4448
4448
  _this.finish(false);
4449
4449
  } else {
4450
- _this._raf = requestAnimationFrame(loop_1);
4450
+ _this._raf = requestAnimationFrame$1(loop_1);
4451
4451
  }
4452
4452
  };
4453
4453
  loop_1();
@@ -7980,6 +7980,7 @@ version: 4.12.0-beta.7
7980
7980
  var _this = this;
7981
7981
  var _b = (_a === void 0 ? {} : _a).align,
7982
7982
  align = _b === void 0 ? ALIGN.CENTER : _b;
7983
+ this._lookedOffset = 0;
7983
7984
  this._checkTranslateSupport = function () {
7984
7985
  var e_1, _a;
7985
7986
  var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
@@ -8339,6 +8340,8 @@ version: 4.12.0-beta.7
8339
8340
  */
8340
8341
  __proto.lookAt = function (pos) {
8341
8342
  var _this = this;
8343
+ var prevOffset = this._offset;
8344
+ var isChangedOffset = this._lookedOffset !== prevOffset;
8342
8345
  var flicking = getFlickingAttached(this._flicking);
8343
8346
  var prevPos = this._position;
8344
8347
  this._position = pos;
@@ -8349,7 +8352,12 @@ version: 4.12.0-beta.7
8349
8352
  if (toggled) {
8350
8353
  void flicking.renderer.render().then(function () {
8351
8354
  _this.updateOffset();
8355
+ _this._lookedOffset = _this._offset;
8352
8356
  });
8357
+ } else if (isChangedOffset) {
8358
+ // sync offset for renderOnlyVisible on resize
8359
+ this.updateOffset();
8360
+ this._lookedOffset = this._offset;
8353
8361
  } else {
8354
8362
  this.applyTransform();
8355
8363
  }
@@ -8524,8 +8532,8 @@ version: 4.12.0-beta.7
8524
8532
  return this;
8525
8533
  };
8526
8534
  /**
8527
- * Update Viewport's height to active panel's height
8528
- * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
8535
+ * Update Viewport's height to visible panel's max height
8536
+ * @ko 현재 활성화된 패널과 보이는 패널의 최대 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
8529
8537
  * @throws {FlickingError}
8530
8538
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
8531
8539
  * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
@@ -8535,9 +8543,17 @@ version: 4.12.0-beta.7
8535
8543
  __proto.updateAdaptiveHeight = function () {
8536
8544
  var flicking = getFlickingAttached(this._flicking);
8537
8545
  var activePanel = flicking.control.activePanel;
8538
- if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
8546
+ var visiblePanels = flicking.visiblePanels;
8547
+ var selectedPanels = __spread$1(visiblePanels);
8548
+ if (activePanel) {
8549
+ selectedPanels.push(activePanel);
8550
+ }
8551
+ if (!flicking.horizontal || !flicking.adaptive || !selectedPanels.length) return;
8552
+ var maxHeight = Math.max.apply(Math, __spread$1(selectedPanels.map(function (panel) {
8553
+ return panel.height;
8554
+ })));
8539
8555
  flicking.viewport.setSize({
8540
- height: activePanel.height
8556
+ height: maxHeight
8541
8557
  });
8542
8558
  };
8543
8559
  /**
@@ -8608,6 +8624,7 @@ version: 4.12.0-beta.7
8608
8624
  };
8609
8625
  __proto._resetInternalValues = function () {
8610
8626
  this._position = 0;
8627
+ this._lookedOffset = 0;
8611
8628
  this._alignPos = 0;
8612
8629
  this._offset = 0;
8613
8630
  this._circularOffset = 0;
@@ -13026,119 +13043,143 @@ version: 4.12.0-beta.7
13026
13043
  * Flicking.VERSION; // ex) 4.0.0
13027
13044
  * ```
13028
13045
  */
13029
- Flicking.VERSION = "4.12.0-beta.7";
13046
+ Flicking.VERSION = "4.12.0-beta.9";
13030
13047
  return Flicking;
13031
13048
  }(Component);
13032
13049
 
13033
- /*
13034
- * Copyright (c) 2015 NAVER Corp.
13035
- * egjs projects are licensed under the MIT license
13036
- */
13037
- /**
13038
- * @extends Component
13039
- * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
13040
- * @requires {@link https://github.com/naver/egjs-component|@egjs/component}
13041
- * @requires {@link https://github.com/naver/egjs-axes|@egjs/axes}
13042
- */
13050
+ var SIDE_EVENTS = {
13051
+ HOLD_START: "sideHoldStart",
13052
+ HOLD_END: "sideHoldEnd",
13053
+ MOVE_START: "sideMoveStart",
13054
+ MOVE: "sideMove",
13055
+ MOVE_END: "sideMoveEnd",
13056
+ WILL_CHANGE: "sideWillChange",
13057
+ CHANGED: "sideChanged"
13058
+ };
13043
13059
  var CrossFlicking = /*#__PURE__*/function (_super) {
13044
13060
  __extends$3(CrossFlicking, _super);
13045
- // Options Setter
13046
- // public set align(val: FlickingOptions["align"]) {
13047
- // this._align = val;
13048
- // }
13049
13061
  function CrossFlicking(root, options) {
13050
- if (options === void 0) {
13051
- options = {};
13052
- }
13053
13062
  var _this = _super.call(this, root, options) || this;
13063
+ _this._syncToCategory = function (index, outerIndex) {
13064
+ if (_this._disableIndexSync) {
13065
+ return;
13066
+ }
13067
+ _this.stopAnimation();
13068
+ _this._sideFlicking.forEach(function (child, i) {
13069
+ var _a = _this._sideState[i],
13070
+ start = _a.start,
13071
+ end = _a.end;
13072
+ if (start <= index && end >= index && outerIndex !== i) {
13073
+ child.stopAnimation();
13074
+ void child.moveTo(index, 0);
13075
+ void _this.moveTo(i, 0);
13076
+ }
13077
+ });
13078
+ };
13079
+ _this._setDraggable = function (direction, draggable) {
13080
+ if (!_this._disableSlideOnHold) {
13081
+ return;
13082
+ }
13083
+ var threshold = draggable ? _this.dragThreshold && _this.dragThreshold >= 10 ? _this.dragThreshold : 10 : Infinity;
13084
+ if (direction === MOVE_DIRECTION.HORIZONTAL === _this.horizontal) {
13085
+ _this.dragThreshold = threshold;
13086
+ } else if (direction === MOVE_DIRECTION.VERTICAL === _this.horizontal) {
13087
+ _this._sideFlicking.forEach(function (child) {
13088
+ child.dragThreshold = threshold;
13089
+ });
13090
+ }
13091
+ };
13092
+ _this._setPreviousSideIndex = function () {
13093
+ _this._sideFlicking.forEach(function (child, i) {
13094
+ var _a = _this._sideState[i],
13095
+ start = _a.start,
13096
+ end = _a.end;
13097
+ if (_this._preserveIndex) {
13098
+ if (_this._nextIndex !== i) {
13099
+ if (child.index < start) {
13100
+ child.stopAnimation();
13101
+ void child.moveTo(start, 0);
13102
+ } else if (child.index > end) {
13103
+ child.stopAnimation();
13104
+ void child.moveTo(end, 0);
13105
+ }
13106
+ }
13107
+ } else {
13108
+ if (_this._nextIndex !== i) {
13109
+ void child.moveTo(start, 0);
13110
+ }
13111
+ }
13112
+ });
13113
+ };
13054
13114
  _this._onHorizontalHoldStart = function () {
13055
- _this.dragThreshold = 10;
13115
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
13056
13116
  _this._moveDirection = null;
13057
13117
  };
13058
13118
  _this._onHorizontalMove = function (e) {
13059
13119
  if (e.isTrusted && !_this._moveDirection) {
13060
- _this._sideFlicking.forEach(function (child) {
13061
- child.dragThreshold = Infinity;
13062
- });
13120
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, false);
13063
13121
  _this._moveDirection = MOVE_DIRECTION.HORIZONTAL;
13064
13122
  }
13065
13123
  };
13066
13124
  _this._onHorizontalMoveEnd = function (e) {
13067
13125
  var visiblePanels = _this.visiblePanels;
13068
- _this._sideFlicking.forEach(function (child) {
13069
- child.dragThreshold = 10;
13070
- });
13071
- _this._moveDirection = null;
13072
13126
  if (visiblePanels.length > 1) {
13073
13127
  _this._nextIndex = e.direction === "NEXT" ? visiblePanels[1].index : visiblePanels[0].index;
13074
13128
  } else {
13075
13129
  _this._nextIndex = visiblePanels[0].index;
13076
13130
  }
13077
- // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 timeout으로 처리
13078
- _this._sideFlicking.forEach(function (child, i) {
13079
- if (_this._nextIndex !== i) {
13080
- var _a = _this._sideState[i],
13081
- start = _a.start,
13082
- end = _a.end;
13083
- if (child.index < start) {
13084
- child.stopAnimation();
13085
- void child.moveTo(start, 0);
13086
- } else if (child.index > end) {
13087
- child.stopAnimation();
13088
- void child.moveTo(end, 0);
13089
- }
13090
- }
13131
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
13132
+ _this._moveDirection = null;
13133
+ // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 requestAnimationFrame 처리
13134
+ requestAnimationFrame(function () {
13135
+ return _this._setPreviousSideIndex();
13091
13136
  });
13092
13137
  if (e.isTrusted) {
13093
13138
  _this._syncToCategory(_this._sideFlicking[_this._nextIndex].index, _this._nextIndex);
13094
13139
  }
13095
13140
  };
13096
13141
  _this._onSideHoldStart = function () {
13097
- _this._sideFlicking.forEach(function (child) {
13098
- child.dragThreshold = 10;
13099
- });
13142
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
13100
13143
  _this._moveDirection = null;
13101
13144
  };
13102
13145
  _this._onSideMove = function (e) {
13103
13146
  if (e.isTrusted && !_this._moveDirection) {
13104
- _this.dragThreshold = Infinity;
13147
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, false);
13105
13148
  _this._moveDirection = MOVE_DIRECTION.VERTICAL;
13106
13149
  }
13107
13150
  };
13108
13151
  _this._onSideMoveEnd = function () {
13109
- _this.dragThreshold = 10;
13152
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
13110
13153
  _this._moveDirection = null;
13111
13154
  };
13112
13155
  _this._onSideChanged = function (e) {
13113
- // this.visiblePanels.length 2보다 크다면 가로 방향 Flicking이 조작 중이라는 것을 의미합니다.
13114
- // 경우 가로 방향 Flicking의 이동이 완전히 끝난 _onHorizontalMoveEnd 에서 syncToCategory할 것이므로 여기서는 하지 않습니다.
13156
+ // If this.visiblePanels.length >= 2, it means that horizontal flicking is being dragged.
13157
+ // In this case, syncToCategory in _onHorizontalMoveEnd will fire after moving finishes, so we don't fire it here.
13115
13158
  if (_this.visiblePanels.length < 2 && _this._sideFlicking[_this.index] === e.currentTarget) {
13116
13159
  _this._syncToCategory(e.index, _this.index);
13117
13160
  }
13118
13161
  };
13162
+ var _a = options.sideOptions,
13163
+ sideOptions = _a === void 0 ? {} : _a,
13164
+ _b = options.preserveIndex,
13165
+ preserveIndex = _b === void 0 ? true : _b,
13166
+ _c = options.disableSlideOnHold,
13167
+ disableSlideOnHold = _c === void 0 ? true : _c,
13168
+ _d = options.disableIndexSync,
13169
+ disableIndexSync = _d === void 0 ? false : _d;
13119
13170
  // Internal states
13120
- _this._sideState = _this._createSideState();
13121
13171
  _this._moveDirection = null;
13122
13172
  _this._nextIndex = 0;
13123
13173
  // Bind options
13124
- _this._sideOptions = options.sideOptions;
13125
- // Create core components
13126
- _this._sideFlicking = _this._createSideFlicking();
13174
+ _this._sideOptions = sideOptions;
13175
+ _this._preserveIndex = preserveIndex;
13176
+ _this._disableSlideOnHold = disableSlideOnHold;
13177
+ _this._disableIndexSync = disableIndexSync;
13127
13178
  return _this;
13128
13179
  }
13129
13180
  var __proto = CrossFlicking.prototype;
13130
13181
  Object.defineProperty(__proto, "sideFlicking", {
13131
13182
  // Components
13132
- /**
13133
- * {@link Control} instance of the Flicking
13134
- * @ko 현재 Flicking에 활성화된 {@link Control} 인스턴스
13135
- * @type {Control}
13136
- * @default SnapControl
13137
- * @readonly
13138
- * @see Control
13139
- * @see SnapControl
13140
- * @see FreeControl
13141
- */
13142
13183
  get: function () {
13143
13184
  return this._sideFlicking;
13144
13185
  },
@@ -13146,16 +13187,6 @@ version: 4.12.0-beta.7
13146
13187
  configurable: true
13147
13188
  });
13148
13189
  Object.defineProperty(__proto, "sideState", {
13149
- // Internal States
13150
- /**
13151
- * Whether Flicking's {@link Flicking#init init()} is called.
13152
- * This is `true` when {@link Flicking#init init()} is called, and is `false` after calling {@link Flicking#destroy destroy()}.
13153
- * @ko Flicking의 {@link Flicking#init init()}이 호출되었는지를 나타내는 멤버 변수.
13154
- * 이 값은 {@link Flicking#init init()}이 호출되었으면 `true`로 변하고, {@link Flicking#destroy destroy()}호출 이후에 다시 `false`로 변경됩니다.
13155
- * @type {boolean}
13156
- * @default false
13157
- * @readonly
13158
- */
13159
13190
  get: function () {
13160
13191
  return this._sideState;
13161
13192
  },
@@ -13164,42 +13195,58 @@ version: 4.12.0-beta.7
13164
13195
  });
13165
13196
  Object.defineProperty(__proto, "sideOptions", {
13166
13197
  // Options Getter
13167
- /**
13168
- * Change active panel index on mouse/touch hold while animating.
13169
- * `index` of the `willChange`/`willRestore` event will be used as new index.
13170
- * @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
13171
- * `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
13172
- * @type {FlickingOptions}
13173
- * @default undefined
13174
- * @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
13175
- */
13176
13198
  get: function () {
13177
13199
  return this._sideOptions;
13178
13200
  },
13201
+ // Options Setter
13202
+ set: function (val) {
13203
+ this._sideOptions = val;
13204
+ },
13205
+ enumerable: false,
13206
+ configurable: true
13207
+ });
13208
+ Object.defineProperty(__proto, "preserveIndex", {
13209
+ get: function () {
13210
+ return this._preserveIndex;
13211
+ },
13212
+ set: function (val) {
13213
+ this._preserveIndex = val;
13214
+ },
13215
+ enumerable: false,
13216
+ configurable: true
13217
+ });
13218
+ Object.defineProperty(__proto, "disableSlideOnHold", {
13219
+ get: function () {
13220
+ return this._disableSlideOnHold;
13221
+ },
13222
+ set: function (val) {
13223
+ this._disableSlideOnHold = val;
13224
+ },
13225
+ enumerable: false,
13226
+ configurable: true
13227
+ });
13228
+ Object.defineProperty(__proto, "disableIndexSync", {
13229
+ get: function () {
13230
+ return this._disableIndexSync;
13231
+ },
13232
+ set: function (val) {
13233
+ this._disableIndexSync = val;
13234
+ },
13179
13235
  enumerable: false,
13180
13236
  configurable: true
13181
13237
  });
13182
- /**
13183
- * Initialize Flicking and move to the default index
13184
- * This is automatically called on Flicking's constructor when `autoInit` is true(default)
13185
- * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
13186
- * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
13187
- * @fires Flicking#ready
13188
- * @return {Promise<void>}
13189
- */
13190
13238
  __proto.init = function () {
13191
13239
  var _this = this;
13192
13240
  return _super.prototype.init.call(this).then(function () {
13193
- return _this._addComponentEvents();
13241
+ _this._sideState = _this._createSideState();
13242
+ _this._sideFlicking = _this._createSideFlicking();
13243
+ _this._addComponentEvents();
13194
13244
  });
13195
13245
  };
13196
- /**
13197
- * Destroy Flicking and remove all event handlers
13198
- * @ko Flicking과 하위 컴포넌트들을 초기 상태로 되돌리고, 부착된 모든 이벤트 핸들러를 제거합니다
13199
- * @return {void}
13200
- */
13201
13246
  __proto.destroy = function () {
13202
- // TODO 모든 child flicking destroy
13247
+ this._sideFlicking.forEach(function (flicking) {
13248
+ flicking.destroy();
13249
+ });
13203
13250
  _super.prototype.destroy.call(this);
13204
13251
  };
13205
13252
  __proto._addComponentEvents = function () {
@@ -13207,110 +13254,110 @@ version: 4.12.0-beta.7
13207
13254
  this.on(EVENTS.HOLD_START, this._onHorizontalHoldStart);
13208
13255
  this.on(EVENTS.MOVE, this._onHorizontalMove);
13209
13256
  this.on(EVENTS.MOVE_END, this._onHorizontalMoveEnd);
13210
- this._sideFlicking.forEach(function (flicking) {
13257
+ this._sideFlicking.forEach(function (flicking, mainIndex) {
13211
13258
  flicking.on(EVENTS.HOLD_START, _this._onSideHoldStart);
13212
13259
  flicking.on(EVENTS.MOVE, _this._onSideMove);
13213
13260
  flicking.on(EVENTS.MOVE_END, _this._onSideMoveEnd);
13214
13261
  flicking.on(EVENTS.CHANGED, _this._onSideChanged);
13262
+ Object.keys(SIDE_EVENTS).forEach(function (name) {
13263
+ flicking.on(EVENTS[name], function (event) {
13264
+ _this.trigger(new ComponentEvent$1(SIDE_EVENTS[name], __assign$2({
13265
+ mainIndex: mainIndex
13266
+ }, event)));
13267
+ });
13268
+ });
13215
13269
  });
13216
13270
  };
13217
13271
  __proto._createSideState = function () {
13218
- var _this = this;
13219
- // data-index로 분류하기 전에 임시로 모든 children에 대해 side flicking으로 해보자.
13220
- // panels에 data-attributes가 붙어있을 때와 안 붙어있을 때를 다르게 처리
13221
- // 붙어있다면 가상의 viewport들을 index 갯수만큼 만들어줘야 한다
13222
13272
  var viewportEl = this.element;
13223
13273
  var cameraEl = this.camera.element;
13224
13274
  var panels = toArray$2(cameraEl.children);
13225
- var sideState = [];
13226
- var sidePanels = "";
13227
- // check data attribute exists
13228
- var groupKeys = [];
13229
- var groupPanels = {};
13230
- var sideCamera = document.createElement("div");
13231
- sideCamera.classList.add(CLASS.CAMERA);
13232
13275
  var isCrossStructure = getDataAttributes(viewportEl, "data-cross-").structure;
13276
+ var sideState = [];
13233
13277
  if (!isCrossStructure) {
13234
- viewportEl.setAttribute("data-cross-structure", "true");
13235
- panels.forEach(function (panel) {
13236
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
13237
- if (groupKey && !includes(groupKeys, groupKey)) {
13238
- groupKeys.push(groupKey);
13239
- groupPanels[groupKey] = [panel];
13240
- } else if (groupKey) {
13241
- groupPanels[groupKey].push(panel);
13242
- }
13243
- });
13278
+ var groupPanels = this._getGroupFromAttribute(panels);
13279
+ var groupKeys = Object.keys(groupPanels);
13244
13280
  if (groupKeys.length) {
13245
- sideState = groupKeys.reduce(function (state, key) {
13246
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
13247
- var element = groupPanels[key].reduce(function (el, panel) {
13248
- sidePanels += panel.outerHTML;
13249
- el.innerHTML += panel.outerHTML;
13250
- return el;
13251
- }, document.createElement("div"));
13252
- return __spread$1(state, [{
13253
- key: key,
13254
- start: start,
13255
- end: start + groupPanels[key].length - 1,
13256
- element: element
13257
- }]);
13258
- }, []);
13281
+ sideState = this._getSideStateFromGroup(groupPanels);
13259
13282
  this.remove(0, this.panelCount - groupKeys.length);
13260
- sideState.forEach(function (_, i) {
13261
- var panel = _this.camera.children[i];
13262
- Array.from(panel.attributes).forEach(function (attribute) {
13263
- return panel.removeAttribute(attribute.name);
13264
- });
13265
- });
13266
13283
  } else {
13267
- sideState = panels.reduce(function (state, panel, i) {
13268
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
13269
- sidePanels += panel.innerHTML;
13270
- return __spread$1(state, [{
13271
- key: i.toString(),
13272
- start: start,
13273
- end: start + panel.children.length - 1,
13274
- element: panel
13275
- }]);
13276
- }, []);
13284
+ sideState = this._getSideStateFromPanels(panels);
13277
13285
  }
13278
- sideCamera.innerHTML = sidePanels;
13279
- sideState.forEach(function (_, i) {
13280
- var panel = _this.camera.children[i];
13281
- [CLASS.VIEWPORT, CLASS.VERTICAL].forEach(function (className) {
13282
- if (!panel.classList.contains(className)) {
13283
- panel.classList.add(className);
13284
- }
13285
- });
13286
- panel.innerHTML = sideCamera.outerHTML;
13287
- });
13286
+ this._createCrossStructure(sideState);
13288
13287
  } else {
13289
- toArray$2(panels[0].children[0].children).forEach(function (panel) {
13290
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
13291
- if (groupKey && !includes(groupKeys, groupKey)) {
13292
- groupKeys.push(groupKey);
13293
- groupPanels[groupKey] = [panel];
13294
- } else if (groupKey) {
13295
- groupPanels[groupKey].push(panel);
13296
- }
13297
- });
13298
- sideState = groupKeys.reduce(function (state, key) {
13299
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
13300
- var element = groupPanels[key].reduce(function (el, panel) {
13301
- el.innerHTML += panel.outerHTML;
13302
- return el;
13303
- }, document.createElement("div"));
13304
- return __spread$1(state, [{
13305
- key: key,
13306
- start: start,
13307
- end: start + groupPanels[key].length - 1,
13308
- element: element
13309
- }]);
13310
- }, []);
13288
+ sideState = this._getSideStateFromCrossStructure(panels);
13311
13289
  }
13290
+ void this.resize();
13312
13291
  return sideState;
13313
13292
  };
13293
+ __proto._createCrossStructure = function (sideState) {
13294
+ var _this = this;
13295
+ var sideCamera = document.createElement("div");
13296
+ var sidePanels = "";
13297
+ sideCamera.classList.add(CLASS.CAMERA);
13298
+ sideState.forEach(function (state, i) {
13299
+ var panel = _this.camera.children[i];
13300
+ sidePanels += state.element.innerHTML;
13301
+ Array.from(panel.attributes).forEach(function (attribute) {
13302
+ return panel.removeAttribute(attribute.name);
13303
+ });
13304
+ });
13305
+ sideCamera.innerHTML = sidePanels;
13306
+ sideState.forEach(function (_, i) {
13307
+ var panel = _this.camera.children[i];
13308
+ [CLASS.VIEWPORT, CLASS.VERTICAL].forEach(function (className) {
13309
+ if (!panel.classList.contains(className)) {
13310
+ panel.classList.add(className);
13311
+ }
13312
+ });
13313
+ panel.innerHTML = sideCamera.outerHTML;
13314
+ });
13315
+ this.element.setAttribute("data-cross-structure", "true");
13316
+ };
13317
+ __proto._getGroupFromAttribute = function (panels) {
13318
+ var groupKeys = [];
13319
+ var groupPanels = {};
13320
+ panels.forEach(function (panel) {
13321
+ var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
13322
+ if (groupKey && !includes(groupKeys, groupKey)) {
13323
+ groupKeys.push(groupKey);
13324
+ groupPanels[groupKey] = [panel];
13325
+ } else if (groupKey) {
13326
+ groupPanels[groupKey].push(panel);
13327
+ }
13328
+ });
13329
+ return groupPanels;
13330
+ };
13331
+ __proto._getSideStateFromGroup = function (groupPanels) {
13332
+ return Object.keys(groupPanels).reduce(function (state, key) {
13333
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
13334
+ var element = groupPanels[key].reduce(function (el, panel) {
13335
+ el.innerHTML += panel.outerHTML;
13336
+ return el;
13337
+ }, document.createElement("div"));
13338
+ return __spread$1(state, [{
13339
+ key: key,
13340
+ start: start,
13341
+ end: start + groupPanels[key].length - 1,
13342
+ element: element
13343
+ }]);
13344
+ }, []);
13345
+ };
13346
+ __proto._getSideStateFromPanels = function (panels) {
13347
+ return panels.reduce(function (state, panel, i) {
13348
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
13349
+ return __spread$1(state, [{
13350
+ key: i.toString(),
13351
+ start: start,
13352
+ end: start + panel.children.length - 1,
13353
+ element: panel
13354
+ }]);
13355
+ }, []);
13356
+ };
13357
+ __proto._getSideStateFromCrossStructure = function (panels) {
13358
+ var groupPanels = this._getGroupFromAttribute(panels);
13359
+ return this._getSideStateFromGroup(groupPanels);
13360
+ };
13314
13361
  __proto._createSideFlicking = function () {
13315
13362
  var _this = this;
13316
13363
  return this.sideState.map(function (state, i) {
@@ -13321,25 +13368,12 @@ version: 4.12.0-beta.7
13321
13368
  }));
13322
13369
  });
13323
13370
  };
13324
- __proto._syncToCategory = function (index, outerIndex) {
13325
- var _this = this;
13326
- this.stopAnimation();
13327
- this._sideFlicking.forEach(function (child, i) {
13328
- var _a = _this._sideState[i],
13329
- start = _a.start,
13330
- end = _a.end;
13331
- if (start <= index && end >= index && outerIndex !== i) {
13332
- child.stopAnimation();
13333
- void child.moveTo(index, 0);
13334
- void _this.moveTo(i, 0);
13335
- }
13336
- });
13337
- };
13338
13371
  return CrossFlicking;
13339
13372
  }(Flicking);
13340
13373
 
13341
13374
  var CrossFlicking$1 = {
13342
13375
  __proto__: null,
13376
+ SIDE_EVENTS: SIDE_EVENTS,
13343
13377
  CrossFlicking: CrossFlicking
13344
13378
  };
13345
13379