@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.
package/dist/flicking.js CHANGED
@@ -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(require('@egjs/component'), require('@egjs/axes'), require('@egjs/imready')) :
@@ -3815,6 +3815,7 @@ version: 4.12.0-beta.7
3815
3815
  var _this = this;
3816
3816
  var _b = (_a === void 0 ? {} : _a).align,
3817
3817
  align = _b === void 0 ? ALIGN.CENTER : _b;
3818
+ this._lookedOffset = 0;
3818
3819
  this._checkTranslateSupport = function () {
3819
3820
  var e_1, _a;
3820
3821
  var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
@@ -4174,6 +4175,8 @@ version: 4.12.0-beta.7
4174
4175
  */
4175
4176
  __proto.lookAt = function (pos) {
4176
4177
  var _this = this;
4178
+ var prevOffset = this._offset;
4179
+ var isChangedOffset = this._lookedOffset !== prevOffset;
4177
4180
  var flicking = getFlickingAttached(this._flicking);
4178
4181
  var prevPos = this._position;
4179
4182
  this._position = pos;
@@ -4184,7 +4187,12 @@ version: 4.12.0-beta.7
4184
4187
  if (toggled) {
4185
4188
  void flicking.renderer.render().then(function () {
4186
4189
  _this.updateOffset();
4190
+ _this._lookedOffset = _this._offset;
4187
4191
  });
4192
+ } else if (isChangedOffset) {
4193
+ // sync offset for renderOnlyVisible on resize
4194
+ this.updateOffset();
4195
+ this._lookedOffset = this._offset;
4188
4196
  } else {
4189
4197
  this.applyTransform();
4190
4198
  }
@@ -4359,8 +4367,8 @@ version: 4.12.0-beta.7
4359
4367
  return this;
4360
4368
  };
4361
4369
  /**
4362
- * Update Viewport's height to active panel's height
4363
- * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4370
+ * Update Viewport's height to visible panel's max height
4371
+ * @ko 현재 활성화된 패널과 보이는 패널의 최대 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4364
4372
  * @throws {FlickingError}
4365
4373
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4366
4374
  * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
@@ -4370,9 +4378,17 @@ version: 4.12.0-beta.7
4370
4378
  __proto.updateAdaptiveHeight = function () {
4371
4379
  var flicking = getFlickingAttached(this._flicking);
4372
4380
  var activePanel = flicking.control.activePanel;
4373
- if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
4381
+ var visiblePanels = flicking.visiblePanels;
4382
+ var selectedPanels = __spread(visiblePanels);
4383
+ if (activePanel) {
4384
+ selectedPanels.push(activePanel);
4385
+ }
4386
+ if (!flicking.horizontal || !flicking.adaptive || !selectedPanels.length) return;
4387
+ var maxHeight = Math.max.apply(Math, __spread(selectedPanels.map(function (panel) {
4388
+ return panel.height;
4389
+ })));
4374
4390
  flicking.viewport.setSize({
4375
- height: activePanel.height
4391
+ height: maxHeight
4376
4392
  });
4377
4393
  };
4378
4394
  /**
@@ -4443,6 +4459,7 @@ version: 4.12.0-beta.7
4443
4459
  };
4444
4460
  __proto._resetInternalValues = function () {
4445
4461
  this._position = 0;
4462
+ this._lookedOffset = 0;
4446
4463
  this._alignPos = 0;
4447
4464
  this._offset = 0;
4448
4465
  this._circularOffset = 0;
@@ -7991,119 +8008,143 @@ version: 4.12.0-beta.7
7991
8008
  * Flicking.VERSION; // ex) 4.0.0
7992
8009
  * ```
7993
8010
  */
7994
- Flicking.VERSION = "4.12.0-beta.7";
8011
+ Flicking.VERSION = "4.12.0-beta.9";
7995
8012
  return Flicking;
7996
8013
  }(Component);
7997
8014
 
7998
- /*
7999
- * Copyright (c) 2015 NAVER Corp.
8000
- * egjs projects are licensed under the MIT license
8001
- */
8002
- /**
8003
- * @extends Component
8004
- * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
8005
- * @requires {@link https://github.com/naver/egjs-component|@egjs/component}
8006
- * @requires {@link https://github.com/naver/egjs-axes|@egjs/axes}
8007
- */
8015
+ var SIDE_EVENTS = {
8016
+ HOLD_START: "sideHoldStart",
8017
+ HOLD_END: "sideHoldEnd",
8018
+ MOVE_START: "sideMoveStart",
8019
+ MOVE: "sideMove",
8020
+ MOVE_END: "sideMoveEnd",
8021
+ WILL_CHANGE: "sideWillChange",
8022
+ CHANGED: "sideChanged"
8023
+ };
8008
8024
  var CrossFlicking = /*#__PURE__*/function (_super) {
8009
8025
  __extends(CrossFlicking, _super);
8010
- // Options Setter
8011
- // public set align(val: FlickingOptions["align"]) {
8012
- // this._align = val;
8013
- // }
8014
8026
  function CrossFlicking(root, options) {
8015
- if (options === void 0) {
8016
- options = {};
8017
- }
8018
8027
  var _this = _super.call(this, root, options) || this;
8028
+ _this._syncToCategory = function (index, outerIndex) {
8029
+ if (_this._disableIndexSync) {
8030
+ return;
8031
+ }
8032
+ _this.stopAnimation();
8033
+ _this._sideFlicking.forEach(function (child, i) {
8034
+ var _a = _this._sideState[i],
8035
+ start = _a.start,
8036
+ end = _a.end;
8037
+ if (start <= index && end >= index && outerIndex !== i) {
8038
+ child.stopAnimation();
8039
+ void child.moveTo(index, 0);
8040
+ void _this.moveTo(i, 0);
8041
+ }
8042
+ });
8043
+ };
8044
+ _this._setDraggable = function (direction, draggable) {
8045
+ if (!_this._disableSlideOnHold) {
8046
+ return;
8047
+ }
8048
+ var threshold = draggable ? _this.dragThreshold && _this.dragThreshold >= 10 ? _this.dragThreshold : 10 : Infinity;
8049
+ if (direction === MOVE_DIRECTION.HORIZONTAL === _this.horizontal) {
8050
+ _this.dragThreshold = threshold;
8051
+ } else if (direction === MOVE_DIRECTION.VERTICAL === _this.horizontal) {
8052
+ _this._sideFlicking.forEach(function (child) {
8053
+ child.dragThreshold = threshold;
8054
+ });
8055
+ }
8056
+ };
8057
+ _this._setPreviousSideIndex = function () {
8058
+ _this._sideFlicking.forEach(function (child, i) {
8059
+ var _a = _this._sideState[i],
8060
+ start = _a.start,
8061
+ end = _a.end;
8062
+ if (_this._preserveIndex) {
8063
+ if (_this._nextIndex !== i) {
8064
+ if (child.index < start) {
8065
+ child.stopAnimation();
8066
+ void child.moveTo(start, 0);
8067
+ } else if (child.index > end) {
8068
+ child.stopAnimation();
8069
+ void child.moveTo(end, 0);
8070
+ }
8071
+ }
8072
+ } else {
8073
+ if (_this._nextIndex !== i) {
8074
+ void child.moveTo(start, 0);
8075
+ }
8076
+ }
8077
+ });
8078
+ };
8019
8079
  _this._onHorizontalHoldStart = function () {
8020
- _this.dragThreshold = 10;
8080
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
8021
8081
  _this._moveDirection = null;
8022
8082
  };
8023
8083
  _this._onHorizontalMove = function (e) {
8024
8084
  if (e.isTrusted && !_this._moveDirection) {
8025
- _this._sideFlicking.forEach(function (child) {
8026
- child.dragThreshold = Infinity;
8027
- });
8085
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, false);
8028
8086
  _this._moveDirection = MOVE_DIRECTION.HORIZONTAL;
8029
8087
  }
8030
8088
  };
8031
8089
  _this._onHorizontalMoveEnd = function (e) {
8032
8090
  var visiblePanels = _this.visiblePanels;
8033
- _this._sideFlicking.forEach(function (child) {
8034
- child.dragThreshold = 10;
8035
- });
8036
- _this._moveDirection = null;
8037
8091
  if (visiblePanels.length > 1) {
8038
8092
  _this._nextIndex = e.direction === "NEXT" ? visiblePanels[1].index : visiblePanels[0].index;
8039
8093
  } else {
8040
8094
  _this._nextIndex = visiblePanels[0].index;
8041
8095
  }
8042
- // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 timeout으로 처리
8043
- _this._sideFlicking.forEach(function (child, i) {
8044
- if (_this._nextIndex !== i) {
8045
- var _a = _this._sideState[i],
8046
- start = _a.start,
8047
- end = _a.end;
8048
- if (child.index < start) {
8049
- child.stopAnimation();
8050
- void child.moveTo(start, 0);
8051
- } else if (child.index > end) {
8052
- child.stopAnimation();
8053
- void child.moveTo(end, 0);
8054
- }
8055
- }
8096
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
8097
+ _this._moveDirection = null;
8098
+ // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 requestAnimationFrame 처리
8099
+ requestAnimationFrame(function () {
8100
+ return _this._setPreviousSideIndex();
8056
8101
  });
8057
8102
  if (e.isTrusted) {
8058
8103
  _this._syncToCategory(_this._sideFlicking[_this._nextIndex].index, _this._nextIndex);
8059
8104
  }
8060
8105
  };
8061
8106
  _this._onSideHoldStart = function () {
8062
- _this._sideFlicking.forEach(function (child) {
8063
- child.dragThreshold = 10;
8064
- });
8107
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
8065
8108
  _this._moveDirection = null;
8066
8109
  };
8067
8110
  _this._onSideMove = function (e) {
8068
8111
  if (e.isTrusted && !_this._moveDirection) {
8069
- _this.dragThreshold = Infinity;
8112
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, false);
8070
8113
  _this._moveDirection = MOVE_DIRECTION.VERTICAL;
8071
8114
  }
8072
8115
  };
8073
8116
  _this._onSideMoveEnd = function () {
8074
- _this.dragThreshold = 10;
8117
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
8075
8118
  _this._moveDirection = null;
8076
8119
  };
8077
8120
  _this._onSideChanged = function (e) {
8078
- // this.visiblePanels.length 2보다 크다면 가로 방향 Flicking이 조작 중이라는 것을 의미합니다.
8079
- // 경우 가로 방향 Flicking의 이동이 완전히 끝난 _onHorizontalMoveEnd 에서 syncToCategory할 것이므로 여기서는 하지 않습니다.
8121
+ // If this.visiblePanels.length >= 2, it means that horizontal flicking is being dragged.
8122
+ // In this case, syncToCategory in _onHorizontalMoveEnd will fire after moving finishes, so we don't fire it here.
8080
8123
  if (_this.visiblePanels.length < 2 && _this._sideFlicking[_this.index] === e.currentTarget) {
8081
8124
  _this._syncToCategory(e.index, _this.index);
8082
8125
  }
8083
8126
  };
8127
+ var _a = options.sideOptions,
8128
+ sideOptions = _a === void 0 ? {} : _a,
8129
+ _b = options.preserveIndex,
8130
+ preserveIndex = _b === void 0 ? true : _b,
8131
+ _c = options.disableSlideOnHold,
8132
+ disableSlideOnHold = _c === void 0 ? true : _c,
8133
+ _d = options.disableIndexSync,
8134
+ disableIndexSync = _d === void 0 ? false : _d;
8084
8135
  // Internal states
8085
- _this._sideState = _this._createSideState();
8086
8136
  _this._moveDirection = null;
8087
8137
  _this._nextIndex = 0;
8088
8138
  // Bind options
8089
- _this._sideOptions = options.sideOptions;
8090
- // Create core components
8091
- _this._sideFlicking = _this._createSideFlicking();
8139
+ _this._sideOptions = sideOptions;
8140
+ _this._preserveIndex = preserveIndex;
8141
+ _this._disableSlideOnHold = disableSlideOnHold;
8142
+ _this._disableIndexSync = disableIndexSync;
8092
8143
  return _this;
8093
8144
  }
8094
8145
  var __proto = CrossFlicking.prototype;
8095
8146
  Object.defineProperty(__proto, "sideFlicking", {
8096
8147
  // Components
8097
- /**
8098
- * {@link Control} instance of the Flicking
8099
- * @ko 현재 Flicking에 활성화된 {@link Control} 인스턴스
8100
- * @type {Control}
8101
- * @default SnapControl
8102
- * @readonly
8103
- * @see Control
8104
- * @see SnapControl
8105
- * @see FreeControl
8106
- */
8107
8148
  get: function () {
8108
8149
  return this._sideFlicking;
8109
8150
  },
@@ -8111,16 +8152,6 @@ version: 4.12.0-beta.7
8111
8152
  configurable: true
8112
8153
  });
8113
8154
  Object.defineProperty(__proto, "sideState", {
8114
- // Internal States
8115
- /**
8116
- * Whether Flicking's {@link Flicking#init init()} is called.
8117
- * This is `true` when {@link Flicking#init init()} is called, and is `false` after calling {@link Flicking#destroy destroy()}.
8118
- * @ko Flicking의 {@link Flicking#init init()}이 호출되었는지를 나타내는 멤버 변수.
8119
- * 이 값은 {@link Flicking#init init()}이 호출되었으면 `true`로 변하고, {@link Flicking#destroy destroy()}호출 이후에 다시 `false`로 변경됩니다.
8120
- * @type {boolean}
8121
- * @default false
8122
- * @readonly
8123
- */
8124
8155
  get: function () {
8125
8156
  return this._sideState;
8126
8157
  },
@@ -8129,42 +8160,58 @@ version: 4.12.0-beta.7
8129
8160
  });
8130
8161
  Object.defineProperty(__proto, "sideOptions", {
8131
8162
  // Options Getter
8132
- /**
8133
- * Change active panel index on mouse/touch hold while animating.
8134
- * `index` of the `willChange`/`willRestore` event will be used as new index.
8135
- * @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
8136
- * `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
8137
- * @type {FlickingOptions}
8138
- * @default undefined
8139
- * @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
8140
- */
8141
8163
  get: function () {
8142
8164
  return this._sideOptions;
8143
8165
  },
8166
+ // Options Setter
8167
+ set: function (val) {
8168
+ this._sideOptions = val;
8169
+ },
8170
+ enumerable: false,
8171
+ configurable: true
8172
+ });
8173
+ Object.defineProperty(__proto, "preserveIndex", {
8174
+ get: function () {
8175
+ return this._preserveIndex;
8176
+ },
8177
+ set: function (val) {
8178
+ this._preserveIndex = val;
8179
+ },
8180
+ enumerable: false,
8181
+ configurable: true
8182
+ });
8183
+ Object.defineProperty(__proto, "disableSlideOnHold", {
8184
+ get: function () {
8185
+ return this._disableSlideOnHold;
8186
+ },
8187
+ set: function (val) {
8188
+ this._disableSlideOnHold = val;
8189
+ },
8190
+ enumerable: false,
8191
+ configurable: true
8192
+ });
8193
+ Object.defineProperty(__proto, "disableIndexSync", {
8194
+ get: function () {
8195
+ return this._disableIndexSync;
8196
+ },
8197
+ set: function (val) {
8198
+ this._disableIndexSync = val;
8199
+ },
8144
8200
  enumerable: false,
8145
8201
  configurable: true
8146
8202
  });
8147
- /**
8148
- * Initialize Flicking and move to the default index
8149
- * This is automatically called on Flicking's constructor when `autoInit` is true(default)
8150
- * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
8151
- * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
8152
- * @fires Flicking#ready
8153
- * @return {Promise<void>}
8154
- */
8155
8203
  __proto.init = function () {
8156
8204
  var _this = this;
8157
8205
  return _super.prototype.init.call(this).then(function () {
8158
- return _this._addComponentEvents();
8206
+ _this._sideState = _this._createSideState();
8207
+ _this._sideFlicking = _this._createSideFlicking();
8208
+ _this._addComponentEvents();
8159
8209
  });
8160
8210
  };
8161
- /**
8162
- * Destroy Flicking and remove all event handlers
8163
- * @ko Flicking과 하위 컴포넌트들을 초기 상태로 되돌리고, 부착된 모든 이벤트 핸들러를 제거합니다
8164
- * @return {void}
8165
- */
8166
8211
  __proto.destroy = function () {
8167
- // TODO 모든 child flicking destroy
8212
+ this._sideFlicking.forEach(function (flicking) {
8213
+ flicking.destroy();
8214
+ });
8168
8215
  _super.prototype.destroy.call(this);
8169
8216
  };
8170
8217
  __proto._addComponentEvents = function () {
@@ -8172,110 +8219,110 @@ version: 4.12.0-beta.7
8172
8219
  this.on(EVENTS.HOLD_START, this._onHorizontalHoldStart);
8173
8220
  this.on(EVENTS.MOVE, this._onHorizontalMove);
8174
8221
  this.on(EVENTS.MOVE_END, this._onHorizontalMoveEnd);
8175
- this._sideFlicking.forEach(function (flicking) {
8222
+ this._sideFlicking.forEach(function (flicking, mainIndex) {
8176
8223
  flicking.on(EVENTS.HOLD_START, _this._onSideHoldStart);
8177
8224
  flicking.on(EVENTS.MOVE, _this._onSideMove);
8178
8225
  flicking.on(EVENTS.MOVE_END, _this._onSideMoveEnd);
8179
8226
  flicking.on(EVENTS.CHANGED, _this._onSideChanged);
8227
+ Object.keys(SIDE_EVENTS).forEach(function (name) {
8228
+ flicking.on(EVENTS[name], function (event) {
8229
+ _this.trigger(new Component.ComponentEvent(SIDE_EVENTS[name], __assign({
8230
+ mainIndex: mainIndex
8231
+ }, event)));
8232
+ });
8233
+ });
8180
8234
  });
8181
8235
  };
8182
8236
  __proto._createSideState = function () {
8183
- var _this = this;
8184
- // data-index로 분류하기 전에 임시로 모든 children에 대해 side flicking으로 해보자.
8185
- // panels에 data-attributes가 붙어있을 때와 안 붙어있을 때를 다르게 처리
8186
- // 붙어있다면 가상의 viewport들을 index 갯수만큼 만들어줘야 한다
8187
8237
  var viewportEl = this.element;
8188
8238
  var cameraEl = this.camera.element;
8189
8239
  var panels = toArray(cameraEl.children);
8190
- var sideState = [];
8191
- var sidePanels = "";
8192
- // check data attribute exists
8193
- var groupKeys = [];
8194
- var groupPanels = {};
8195
- var sideCamera = document.createElement("div");
8196
- sideCamera.classList.add(CLASS.CAMERA);
8197
8240
  var isCrossStructure = getDataAttributes(viewportEl, "data-cross-").structure;
8241
+ var sideState = [];
8198
8242
  if (!isCrossStructure) {
8199
- viewportEl.setAttribute("data-cross-structure", "true");
8200
- panels.forEach(function (panel) {
8201
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8202
- if (groupKey && !includes(groupKeys, groupKey)) {
8203
- groupKeys.push(groupKey);
8204
- groupPanels[groupKey] = [panel];
8205
- } else if (groupKey) {
8206
- groupPanels[groupKey].push(panel);
8207
- }
8208
- });
8243
+ var groupPanels = this._getGroupFromAttribute(panels);
8244
+ var groupKeys = Object.keys(groupPanels);
8209
8245
  if (groupKeys.length) {
8210
- sideState = groupKeys.reduce(function (state, key) {
8211
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
8212
- var element = groupPanels[key].reduce(function (el, panel) {
8213
- sidePanels += panel.outerHTML;
8214
- el.innerHTML += panel.outerHTML;
8215
- return el;
8216
- }, document.createElement("div"));
8217
- return __spread(state, [{
8218
- key: key,
8219
- start: start,
8220
- end: start + groupPanels[key].length - 1,
8221
- element: element
8222
- }]);
8223
- }, []);
8246
+ sideState = this._getSideStateFromGroup(groupPanels);
8224
8247
  this.remove(0, this.panelCount - groupKeys.length);
8225
- sideState.forEach(function (_, i) {
8226
- var panel = _this.camera.children[i];
8227
- Array.from(panel.attributes).forEach(function (attribute) {
8228
- return panel.removeAttribute(attribute.name);
8229
- });
8230
- });
8231
8248
  } else {
8232
- sideState = panels.reduce(function (state, panel, i) {
8233
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
8234
- sidePanels += panel.innerHTML;
8235
- return __spread(state, [{
8236
- key: i.toString(),
8237
- start: start,
8238
- end: start + panel.children.length - 1,
8239
- element: panel
8240
- }]);
8241
- }, []);
8249
+ sideState = this._getSideStateFromPanels(panels);
8242
8250
  }
8243
- sideCamera.innerHTML = sidePanels;
8244
- sideState.forEach(function (_, i) {
8245
- var panel = _this.camera.children[i];
8246
- [CLASS.VIEWPORT, CLASS.VERTICAL].forEach(function (className) {
8247
- if (!panel.classList.contains(className)) {
8248
- panel.classList.add(className);
8249
- }
8250
- });
8251
- panel.innerHTML = sideCamera.outerHTML;
8252
- });
8251
+ this._createCrossStructure(sideState);
8253
8252
  } else {
8254
- toArray(panels[0].children[0].children).forEach(function (panel) {
8255
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8256
- if (groupKey && !includes(groupKeys, groupKey)) {
8257
- groupKeys.push(groupKey);
8258
- groupPanels[groupKey] = [panel];
8259
- } else if (groupKey) {
8260
- groupPanels[groupKey].push(panel);
8261
- }
8262
- });
8263
- sideState = groupKeys.reduce(function (state, key) {
8264
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
8265
- var element = groupPanels[key].reduce(function (el, panel) {
8266
- el.innerHTML += panel.outerHTML;
8267
- return el;
8268
- }, document.createElement("div"));
8269
- return __spread(state, [{
8270
- key: key,
8271
- start: start,
8272
- end: start + groupPanels[key].length - 1,
8273
- element: element
8274
- }]);
8275
- }, []);
8253
+ sideState = this._getSideStateFromCrossStructure(panels);
8276
8254
  }
8255
+ void this.resize();
8277
8256
  return sideState;
8278
8257
  };
8258
+ __proto._createCrossStructure = function (sideState) {
8259
+ var _this = this;
8260
+ var sideCamera = document.createElement("div");
8261
+ var sidePanels = "";
8262
+ sideCamera.classList.add(CLASS.CAMERA);
8263
+ sideState.forEach(function (state, i) {
8264
+ var panel = _this.camera.children[i];
8265
+ sidePanels += state.element.innerHTML;
8266
+ Array.from(panel.attributes).forEach(function (attribute) {
8267
+ return panel.removeAttribute(attribute.name);
8268
+ });
8269
+ });
8270
+ sideCamera.innerHTML = sidePanels;
8271
+ sideState.forEach(function (_, i) {
8272
+ var panel = _this.camera.children[i];
8273
+ [CLASS.VIEWPORT, CLASS.VERTICAL].forEach(function (className) {
8274
+ if (!panel.classList.contains(className)) {
8275
+ panel.classList.add(className);
8276
+ }
8277
+ });
8278
+ panel.innerHTML = sideCamera.outerHTML;
8279
+ });
8280
+ this.element.setAttribute("data-cross-structure", "true");
8281
+ };
8282
+ __proto._getGroupFromAttribute = function (panels) {
8283
+ var groupKeys = [];
8284
+ var groupPanels = {};
8285
+ panels.forEach(function (panel) {
8286
+ var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8287
+ if (groupKey && !includes(groupKeys, groupKey)) {
8288
+ groupKeys.push(groupKey);
8289
+ groupPanels[groupKey] = [panel];
8290
+ } else if (groupKey) {
8291
+ groupPanels[groupKey].push(panel);
8292
+ }
8293
+ });
8294
+ return groupPanels;
8295
+ };
8296
+ __proto._getSideStateFromGroup = function (groupPanels) {
8297
+ return Object.keys(groupPanels).reduce(function (state, key) {
8298
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
8299
+ var element = groupPanels[key].reduce(function (el, panel) {
8300
+ el.innerHTML += panel.outerHTML;
8301
+ return el;
8302
+ }, document.createElement("div"));
8303
+ return __spread(state, [{
8304
+ key: key,
8305
+ start: start,
8306
+ end: start + groupPanels[key].length - 1,
8307
+ element: element
8308
+ }]);
8309
+ }, []);
8310
+ };
8311
+ __proto._getSideStateFromPanels = function (panels) {
8312
+ return panels.reduce(function (state, panel, i) {
8313
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
8314
+ return __spread(state, [{
8315
+ key: i.toString(),
8316
+ start: start,
8317
+ end: start + panel.children.length - 1,
8318
+ element: panel
8319
+ }]);
8320
+ }, []);
8321
+ };
8322
+ __proto._getSideStateFromCrossStructure = function (panels) {
8323
+ var groupPanels = this._getGroupFromAttribute(panels);
8324
+ return this._getSideStateFromGroup(groupPanels);
8325
+ };
8279
8326
  __proto._createSideFlicking = function () {
8280
8327
  var _this = this;
8281
8328
  return this.sideState.map(function (state, i) {
@@ -8286,25 +8333,12 @@ version: 4.12.0-beta.7
8286
8333
  }));
8287
8334
  });
8288
8335
  };
8289
- __proto._syncToCategory = function (index, outerIndex) {
8290
- var _this = this;
8291
- this.stopAnimation();
8292
- this._sideFlicking.forEach(function (child, i) {
8293
- var _a = _this._sideState[i],
8294
- start = _a.start,
8295
- end = _a.end;
8296
- if (start <= index && end >= index && outerIndex !== i) {
8297
- child.stopAnimation();
8298
- void child.moveTo(index, 0);
8299
- void _this.moveTo(i, 0);
8300
- }
8301
- });
8302
- };
8303
8336
  return CrossFlicking;
8304
8337
  }(Flicking);
8305
8338
 
8306
8339
  var CrossFlicking$1 = {
8307
8340
  __proto__: null,
8341
+ SIDE_EVENTS: SIDE_EVENTS,
8308
8342
  CrossFlicking: CrossFlicking
8309
8343
  };
8310
8344