@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
  'use strict';
10
10
 
@@ -3746,6 +3746,7 @@ var Camera = /*#__PURE__*/function () {
3746
3746
  var _this = this;
3747
3747
  var _b = (_a === void 0 ? {} : _a).align,
3748
3748
  align = _b === void 0 ? ALIGN.CENTER : _b;
3749
+ this._lookedOffset = 0;
3749
3750
  this._checkTranslateSupport = function () {
3750
3751
  var e_1, _a;
3751
3752
  var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
@@ -4105,6 +4106,8 @@ var Camera = /*#__PURE__*/function () {
4105
4106
  */
4106
4107
  __proto.lookAt = function (pos) {
4107
4108
  var _this = this;
4109
+ var prevOffset = this._offset;
4110
+ var isChangedOffset = this._lookedOffset !== prevOffset;
4108
4111
  var flicking = getFlickingAttached(this._flicking);
4109
4112
  var prevPos = this._position;
4110
4113
  this._position = pos;
@@ -4115,7 +4118,12 @@ var Camera = /*#__PURE__*/function () {
4115
4118
  if (toggled) {
4116
4119
  void flicking.renderer.render().then(function () {
4117
4120
  _this.updateOffset();
4121
+ _this._lookedOffset = _this._offset;
4118
4122
  });
4123
+ } else if (isChangedOffset) {
4124
+ // sync offset for renderOnlyVisible on resize
4125
+ this.updateOffset();
4126
+ this._lookedOffset = this._offset;
4119
4127
  } else {
4120
4128
  this.applyTransform();
4121
4129
  }
@@ -4290,8 +4298,8 @@ var Camera = /*#__PURE__*/function () {
4290
4298
  return this;
4291
4299
  };
4292
4300
  /**
4293
- * Update Viewport's height to active panel's height
4294
- * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4301
+ * Update Viewport's height to visible panel's max height
4302
+ * @ko 현재 활성화된 패널과 보이는 패널의 최대 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4295
4303
  * @throws {FlickingError}
4296
4304
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4297
4305
  * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
@@ -4301,9 +4309,17 @@ var Camera = /*#__PURE__*/function () {
4301
4309
  __proto.updateAdaptiveHeight = function () {
4302
4310
  var flicking = getFlickingAttached(this._flicking);
4303
4311
  var activePanel = flicking.control.activePanel;
4304
- if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
4312
+ var visiblePanels = flicking.visiblePanels;
4313
+ var selectedPanels = __spread(visiblePanels);
4314
+ if (activePanel) {
4315
+ selectedPanels.push(activePanel);
4316
+ }
4317
+ if (!flicking.horizontal || !flicking.adaptive || !selectedPanels.length) return;
4318
+ var maxHeight = Math.max.apply(Math, __spread(selectedPanels.map(function (panel) {
4319
+ return panel.height;
4320
+ })));
4305
4321
  flicking.viewport.setSize({
4306
- height: activePanel.height
4322
+ height: maxHeight
4307
4323
  });
4308
4324
  };
4309
4325
  /**
@@ -4374,6 +4390,7 @@ var Camera = /*#__PURE__*/function () {
4374
4390
  };
4375
4391
  __proto._resetInternalValues = function () {
4376
4392
  this._position = 0;
4393
+ this._lookedOffset = 0;
4377
4394
  this._alignPos = 0;
4378
4395
  this._offset = 0;
4379
4396
  this._circularOffset = 0;
@@ -7895,119 +7912,143 @@ var Flicking = /*#__PURE__*/function (_super) {
7895
7912
  * Flicking.VERSION; // ex) 4.0.0
7896
7913
  * ```
7897
7914
  */
7898
- Flicking.VERSION = "4.12.0-beta.7";
7915
+ Flicking.VERSION = "4.12.0-beta.9";
7899
7916
  return Flicking;
7900
7917
  }(Component);
7901
7918
 
7902
- /*
7903
- * Copyright (c) 2015 NAVER Corp.
7904
- * egjs projects are licensed under the MIT license
7905
- */
7906
- /**
7907
- * @extends Component
7908
- * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
7909
- * @requires {@link https://github.com/naver/egjs-component|@egjs/component}
7910
- * @requires {@link https://github.com/naver/egjs-axes|@egjs/axes}
7911
- */
7919
+ var SIDE_EVENTS = {
7920
+ HOLD_START: "sideHoldStart",
7921
+ HOLD_END: "sideHoldEnd",
7922
+ MOVE_START: "sideMoveStart",
7923
+ MOVE: "sideMove",
7924
+ MOVE_END: "sideMoveEnd",
7925
+ WILL_CHANGE: "sideWillChange",
7926
+ CHANGED: "sideChanged"
7927
+ };
7912
7928
  var CrossFlicking = /*#__PURE__*/function (_super) {
7913
7929
  __extends(CrossFlicking, _super);
7914
- // Options Setter
7915
- // public set align(val: FlickingOptions["align"]) {
7916
- // this._align = val;
7917
- // }
7918
7930
  function CrossFlicking(root, options) {
7919
- if (options === void 0) {
7920
- options = {};
7921
- }
7922
7931
  var _this = _super.call(this, root, options) || this;
7932
+ _this._syncToCategory = function (index, outerIndex) {
7933
+ if (_this._disableIndexSync) {
7934
+ return;
7935
+ }
7936
+ _this.stopAnimation();
7937
+ _this._sideFlicking.forEach(function (child, i) {
7938
+ var _a = _this._sideState[i],
7939
+ start = _a.start,
7940
+ end = _a.end;
7941
+ if (start <= index && end >= index && outerIndex !== i) {
7942
+ child.stopAnimation();
7943
+ void child.moveTo(index, 0);
7944
+ void _this.moveTo(i, 0);
7945
+ }
7946
+ });
7947
+ };
7948
+ _this._setDraggable = function (direction, draggable) {
7949
+ if (!_this._disableSlideOnHold) {
7950
+ return;
7951
+ }
7952
+ var threshold = draggable ? _this.dragThreshold && _this.dragThreshold >= 10 ? _this.dragThreshold : 10 : Infinity;
7953
+ if (direction === MOVE_DIRECTION.HORIZONTAL === _this.horizontal) {
7954
+ _this.dragThreshold = threshold;
7955
+ } else if (direction === MOVE_DIRECTION.VERTICAL === _this.horizontal) {
7956
+ _this._sideFlicking.forEach(function (child) {
7957
+ child.dragThreshold = threshold;
7958
+ });
7959
+ }
7960
+ };
7961
+ _this._setPreviousSideIndex = function () {
7962
+ _this._sideFlicking.forEach(function (child, i) {
7963
+ var _a = _this._sideState[i],
7964
+ start = _a.start,
7965
+ end = _a.end;
7966
+ if (_this._preserveIndex) {
7967
+ if (_this._nextIndex !== i) {
7968
+ if (child.index < start) {
7969
+ child.stopAnimation();
7970
+ void child.moveTo(start, 0);
7971
+ } else if (child.index > end) {
7972
+ child.stopAnimation();
7973
+ void child.moveTo(end, 0);
7974
+ }
7975
+ }
7976
+ } else {
7977
+ if (_this._nextIndex !== i) {
7978
+ void child.moveTo(start, 0);
7979
+ }
7980
+ }
7981
+ });
7982
+ };
7923
7983
  _this._onHorizontalHoldStart = function () {
7924
- _this.dragThreshold = 10;
7984
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
7925
7985
  _this._moveDirection = null;
7926
7986
  };
7927
7987
  _this._onHorizontalMove = function (e) {
7928
7988
  if (e.isTrusted && !_this._moveDirection) {
7929
- _this._sideFlicking.forEach(function (child) {
7930
- child.dragThreshold = Infinity;
7931
- });
7989
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, false);
7932
7990
  _this._moveDirection = MOVE_DIRECTION.HORIZONTAL;
7933
7991
  }
7934
7992
  };
7935
7993
  _this._onHorizontalMoveEnd = function (e) {
7936
7994
  var visiblePanels = _this.visiblePanels;
7937
- _this._sideFlicking.forEach(function (child) {
7938
- child.dragThreshold = 10;
7939
- });
7940
- _this._moveDirection = null;
7941
7995
  if (visiblePanels.length > 1) {
7942
7996
  _this._nextIndex = e.direction === "NEXT" ? visiblePanels[1].index : visiblePanels[0].index;
7943
7997
  } else {
7944
7998
  _this._nextIndex = visiblePanels[0].index;
7945
7999
  }
7946
- // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 timeout으로 처리
7947
- _this._sideFlicking.forEach(function (child, i) {
7948
- if (_this._nextIndex !== i) {
7949
- var _a = _this._sideState[i],
7950
- start = _a.start,
7951
- end = _a.end;
7952
- if (child.index < start) {
7953
- child.stopAnimation();
7954
- void child.moveTo(start, 0);
7955
- } else if (child.index > end) {
7956
- child.stopAnimation();
7957
- void child.moveTo(end, 0);
7958
- }
7959
- }
8000
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
8001
+ _this._moveDirection = null;
8002
+ // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 requestAnimationFrame 처리
8003
+ requestAnimationFrame(function () {
8004
+ return _this._setPreviousSideIndex();
7960
8005
  });
7961
8006
  if (e.isTrusted) {
7962
8007
  _this._syncToCategory(_this._sideFlicking[_this._nextIndex].index, _this._nextIndex);
7963
8008
  }
7964
8009
  };
7965
8010
  _this._onSideHoldStart = function () {
7966
- _this._sideFlicking.forEach(function (child) {
7967
- child.dragThreshold = 10;
7968
- });
8011
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
7969
8012
  _this._moveDirection = null;
7970
8013
  };
7971
8014
  _this._onSideMove = function (e) {
7972
8015
  if (e.isTrusted && !_this._moveDirection) {
7973
- _this.dragThreshold = Infinity;
8016
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, false);
7974
8017
  _this._moveDirection = MOVE_DIRECTION.VERTICAL;
7975
8018
  }
7976
8019
  };
7977
8020
  _this._onSideMoveEnd = function () {
7978
- _this.dragThreshold = 10;
8021
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
7979
8022
  _this._moveDirection = null;
7980
8023
  };
7981
8024
  _this._onSideChanged = function (e) {
7982
- // this.visiblePanels.length 2보다 크다면 가로 방향 Flicking이 조작 중이라는 것을 의미합니다.
7983
- // 경우 가로 방향 Flicking의 이동이 완전히 끝난 _onHorizontalMoveEnd 에서 syncToCategory할 것이므로 여기서는 하지 않습니다.
8025
+ // If this.visiblePanels.length >= 2, it means that horizontal flicking is being dragged.
8026
+ // In this case, syncToCategory in _onHorizontalMoveEnd will fire after moving finishes, so we don't fire it here.
7984
8027
  if (_this.visiblePanels.length < 2 && _this._sideFlicking[_this.index] === e.currentTarget) {
7985
8028
  _this._syncToCategory(e.index, _this.index);
7986
8029
  }
7987
8030
  };
8031
+ var _a = options.sideOptions,
8032
+ sideOptions = _a === void 0 ? {} : _a,
8033
+ _b = options.preserveIndex,
8034
+ preserveIndex = _b === void 0 ? true : _b,
8035
+ _c = options.disableSlideOnHold,
8036
+ disableSlideOnHold = _c === void 0 ? true : _c,
8037
+ _d = options.disableIndexSync,
8038
+ disableIndexSync = _d === void 0 ? false : _d;
7988
8039
  // Internal states
7989
- _this._sideState = _this._createSideState();
7990
8040
  _this._moveDirection = null;
7991
8041
  _this._nextIndex = 0;
7992
8042
  // Bind options
7993
- _this._sideOptions = options.sideOptions;
7994
- // Create core components
7995
- _this._sideFlicking = _this._createSideFlicking();
8043
+ _this._sideOptions = sideOptions;
8044
+ _this._preserveIndex = preserveIndex;
8045
+ _this._disableSlideOnHold = disableSlideOnHold;
8046
+ _this._disableIndexSync = disableIndexSync;
7996
8047
  return _this;
7997
8048
  }
7998
8049
  var __proto = CrossFlicking.prototype;
7999
8050
  Object.defineProperty(__proto, "sideFlicking", {
8000
8051
  // Components
8001
- /**
8002
- * {@link Control} instance of the Flicking
8003
- * @ko 현재 Flicking에 활성화된 {@link Control} 인스턴스
8004
- * @type {Control}
8005
- * @default SnapControl
8006
- * @readonly
8007
- * @see Control
8008
- * @see SnapControl
8009
- * @see FreeControl
8010
- */
8011
8052
  get: function () {
8012
8053
  return this._sideFlicking;
8013
8054
  },
@@ -8015,16 +8056,6 @@ var CrossFlicking = /*#__PURE__*/function (_super) {
8015
8056
  configurable: true
8016
8057
  });
8017
8058
  Object.defineProperty(__proto, "sideState", {
8018
- // Internal States
8019
- /**
8020
- * Whether Flicking's {@link Flicking#init init()} is called.
8021
- * This is `true` when {@link Flicking#init init()} is called, and is `false` after calling {@link Flicking#destroy destroy()}.
8022
- * @ko Flicking의 {@link Flicking#init init()}이 호출되었는지를 나타내는 멤버 변수.
8023
- * 이 값은 {@link Flicking#init init()}이 호출되었으면 `true`로 변하고, {@link Flicking#destroy destroy()}호출 이후에 다시 `false`로 변경됩니다.
8024
- * @type {boolean}
8025
- * @default false
8026
- * @readonly
8027
- */
8028
8059
  get: function () {
8029
8060
  return this._sideState;
8030
8061
  },
@@ -8033,42 +8064,58 @@ var CrossFlicking = /*#__PURE__*/function (_super) {
8033
8064
  });
8034
8065
  Object.defineProperty(__proto, "sideOptions", {
8035
8066
  // Options Getter
8036
- /**
8037
- * Change active panel index on mouse/touch hold while animating.
8038
- * `index` of the `willChange`/`willRestore` event will be used as new index.
8039
- * @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
8040
- * `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
8041
- * @type {FlickingOptions}
8042
- * @default undefined
8043
- * @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
8044
- */
8045
8067
  get: function () {
8046
8068
  return this._sideOptions;
8047
8069
  },
8070
+ // Options Setter
8071
+ set: function (val) {
8072
+ this._sideOptions = val;
8073
+ },
8074
+ enumerable: false,
8075
+ configurable: true
8076
+ });
8077
+ Object.defineProperty(__proto, "preserveIndex", {
8078
+ get: function () {
8079
+ return this._preserveIndex;
8080
+ },
8081
+ set: function (val) {
8082
+ this._preserveIndex = val;
8083
+ },
8084
+ enumerable: false,
8085
+ configurable: true
8086
+ });
8087
+ Object.defineProperty(__proto, "disableSlideOnHold", {
8088
+ get: function () {
8089
+ return this._disableSlideOnHold;
8090
+ },
8091
+ set: function (val) {
8092
+ this._disableSlideOnHold = val;
8093
+ },
8094
+ enumerable: false,
8095
+ configurable: true
8096
+ });
8097
+ Object.defineProperty(__proto, "disableIndexSync", {
8098
+ get: function () {
8099
+ return this._disableIndexSync;
8100
+ },
8101
+ set: function (val) {
8102
+ this._disableIndexSync = val;
8103
+ },
8048
8104
  enumerable: false,
8049
8105
  configurable: true
8050
8106
  });
8051
- /**
8052
- * Initialize Flicking and move to the default index
8053
- * This is automatically called on Flicking's constructor when `autoInit` is true(default)
8054
- * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
8055
- * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
8056
- * @fires Flicking#ready
8057
- * @return {Promise<void>}
8058
- */
8059
8107
  __proto.init = function () {
8060
8108
  var _this = this;
8061
8109
  return _super.prototype.init.call(this).then(function () {
8062
- return _this._addComponentEvents();
8110
+ _this._sideState = _this._createSideState();
8111
+ _this._sideFlicking = _this._createSideFlicking();
8112
+ _this._addComponentEvents();
8063
8113
  });
8064
8114
  };
8065
- /**
8066
- * Destroy Flicking and remove all event handlers
8067
- * @ko Flicking과 하위 컴포넌트들을 초기 상태로 되돌리고, 부착된 모든 이벤트 핸들러를 제거합니다
8068
- * @return {void}
8069
- */
8070
8115
  __proto.destroy = function () {
8071
- // TODO 모든 child flicking destroy
8116
+ this._sideFlicking.forEach(function (flicking) {
8117
+ flicking.destroy();
8118
+ });
8072
8119
  _super.prototype.destroy.call(this);
8073
8120
  };
8074
8121
  __proto._addComponentEvents = function () {
@@ -8076,110 +8123,110 @@ var CrossFlicking = /*#__PURE__*/function (_super) {
8076
8123
  this.on(EVENTS.HOLD_START, this._onHorizontalHoldStart);
8077
8124
  this.on(EVENTS.MOVE, this._onHorizontalMove);
8078
8125
  this.on(EVENTS.MOVE_END, this._onHorizontalMoveEnd);
8079
- this._sideFlicking.forEach(function (flicking) {
8126
+ this._sideFlicking.forEach(function (flicking, mainIndex) {
8080
8127
  flicking.on(EVENTS.HOLD_START, _this._onSideHoldStart);
8081
8128
  flicking.on(EVENTS.MOVE, _this._onSideMove);
8082
8129
  flicking.on(EVENTS.MOVE_END, _this._onSideMoveEnd);
8083
8130
  flicking.on(EVENTS.CHANGED, _this._onSideChanged);
8131
+ Object.keys(SIDE_EVENTS).forEach(function (name) {
8132
+ flicking.on(EVENTS[name], function (event) {
8133
+ _this.trigger(new Component.ComponentEvent(SIDE_EVENTS[name], __assign({
8134
+ mainIndex: mainIndex
8135
+ }, event)));
8136
+ });
8137
+ });
8084
8138
  });
8085
8139
  };
8086
8140
  __proto._createSideState = function () {
8087
- var _this = this;
8088
- // data-index로 분류하기 전에 임시로 모든 children에 대해 side flicking으로 해보자.
8089
- // panels에 data-attributes가 붙어있을 때와 안 붙어있을 때를 다르게 처리
8090
- // 붙어있다면 가상의 viewport들을 index 갯수만큼 만들어줘야 한다
8091
8141
  var viewportEl = this.element;
8092
8142
  var cameraEl = this.camera.element;
8093
8143
  var panels = toArray(cameraEl.children);
8094
- var sideState = [];
8095
- var sidePanels = "";
8096
- // check data attribute exists
8097
- var groupKeys = [];
8098
- var groupPanels = {};
8099
- var sideCamera = document.createElement("div");
8100
- sideCamera.classList.add(CLASS.CAMERA);
8101
8144
  var isCrossStructure = getDataAttributes(viewportEl, "data-cross-").structure;
8145
+ var sideState = [];
8102
8146
  if (!isCrossStructure) {
8103
- viewportEl.setAttribute("data-cross-structure", "true");
8104
- panels.forEach(function (panel) {
8105
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8106
- if (groupKey && !includes(groupKeys, groupKey)) {
8107
- groupKeys.push(groupKey);
8108
- groupPanels[groupKey] = [panel];
8109
- } else if (groupKey) {
8110
- groupPanels[groupKey].push(panel);
8111
- }
8112
- });
8147
+ var groupPanels = this._getGroupFromAttribute(panels);
8148
+ var groupKeys = Object.keys(groupPanels);
8113
8149
  if (groupKeys.length) {
8114
- sideState = groupKeys.reduce(function (state, key) {
8115
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
8116
- var element = groupPanels[key].reduce(function (el, panel) {
8117
- sidePanels += panel.outerHTML;
8118
- el.innerHTML += panel.outerHTML;
8119
- return el;
8120
- }, document.createElement("div"));
8121
- return __spread(state, [{
8122
- key: key,
8123
- start: start,
8124
- end: start + groupPanels[key].length - 1,
8125
- element: element
8126
- }]);
8127
- }, []);
8150
+ sideState = this._getSideStateFromGroup(groupPanels);
8128
8151
  this.remove(0, this.panelCount - groupKeys.length);
8129
- sideState.forEach(function (_, i) {
8130
- var panel = _this.camera.children[i];
8131
- Array.from(panel.attributes).forEach(function (attribute) {
8132
- return panel.removeAttribute(attribute.name);
8133
- });
8134
- });
8135
8152
  } else {
8136
- sideState = panels.reduce(function (state, panel, i) {
8137
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
8138
- sidePanels += panel.innerHTML;
8139
- return __spread(state, [{
8140
- key: i.toString(),
8141
- start: start,
8142
- end: start + panel.children.length - 1,
8143
- element: panel
8144
- }]);
8145
- }, []);
8153
+ sideState = this._getSideStateFromPanels(panels);
8146
8154
  }
8147
- sideCamera.innerHTML = sidePanels;
8148
- sideState.forEach(function (_, i) {
8149
- var panel = _this.camera.children[i];
8150
- [CLASS.VIEWPORT, CLASS.VERTICAL].forEach(function (className) {
8151
- if (!panel.classList.contains(className)) {
8152
- panel.classList.add(className);
8153
- }
8154
- });
8155
- panel.innerHTML = sideCamera.outerHTML;
8156
- });
8155
+ this._createCrossStructure(sideState);
8157
8156
  } else {
8158
- toArray(panels[0].children[0].children).forEach(function (panel) {
8159
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8160
- if (groupKey && !includes(groupKeys, groupKey)) {
8161
- groupKeys.push(groupKey);
8162
- groupPanels[groupKey] = [panel];
8163
- } else if (groupKey) {
8164
- groupPanels[groupKey].push(panel);
8165
- }
8166
- });
8167
- sideState = groupKeys.reduce(function (state, key) {
8168
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
8169
- var element = groupPanels[key].reduce(function (el, panel) {
8170
- el.innerHTML += panel.outerHTML;
8171
- return el;
8172
- }, document.createElement("div"));
8173
- return __spread(state, [{
8174
- key: key,
8175
- start: start,
8176
- end: start + groupPanels[key].length - 1,
8177
- element: element
8178
- }]);
8179
- }, []);
8157
+ sideState = this._getSideStateFromCrossStructure(panels);
8180
8158
  }
8159
+ void this.resize();
8181
8160
  return sideState;
8182
8161
  };
8162
+ __proto._createCrossStructure = function (sideState) {
8163
+ var _this = this;
8164
+ var sideCamera = document.createElement("div");
8165
+ var sidePanels = "";
8166
+ sideCamera.classList.add(CLASS.CAMERA);
8167
+ sideState.forEach(function (state, i) {
8168
+ var panel = _this.camera.children[i];
8169
+ sidePanels += state.element.innerHTML;
8170
+ Array.from(panel.attributes).forEach(function (attribute) {
8171
+ return panel.removeAttribute(attribute.name);
8172
+ });
8173
+ });
8174
+ sideCamera.innerHTML = sidePanels;
8175
+ sideState.forEach(function (_, i) {
8176
+ var panel = _this.camera.children[i];
8177
+ [CLASS.VIEWPORT, CLASS.VERTICAL].forEach(function (className) {
8178
+ if (!panel.classList.contains(className)) {
8179
+ panel.classList.add(className);
8180
+ }
8181
+ });
8182
+ panel.innerHTML = sideCamera.outerHTML;
8183
+ });
8184
+ this.element.setAttribute("data-cross-structure", "true");
8185
+ };
8186
+ __proto._getGroupFromAttribute = function (panels) {
8187
+ var groupKeys = [];
8188
+ var groupPanels = {};
8189
+ panels.forEach(function (panel) {
8190
+ var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8191
+ if (groupKey && !includes(groupKeys, groupKey)) {
8192
+ groupKeys.push(groupKey);
8193
+ groupPanels[groupKey] = [panel];
8194
+ } else if (groupKey) {
8195
+ groupPanels[groupKey].push(panel);
8196
+ }
8197
+ });
8198
+ return groupPanels;
8199
+ };
8200
+ __proto._getSideStateFromGroup = function (groupPanels) {
8201
+ return Object.keys(groupPanels).reduce(function (state, key) {
8202
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
8203
+ var element = groupPanels[key].reduce(function (el, panel) {
8204
+ el.innerHTML += panel.outerHTML;
8205
+ return el;
8206
+ }, document.createElement("div"));
8207
+ return __spread(state, [{
8208
+ key: key,
8209
+ start: start,
8210
+ end: start + groupPanels[key].length - 1,
8211
+ element: element
8212
+ }]);
8213
+ }, []);
8214
+ };
8215
+ __proto._getSideStateFromPanels = function (panels) {
8216
+ return panels.reduce(function (state, panel, i) {
8217
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
8218
+ return __spread(state, [{
8219
+ key: i.toString(),
8220
+ start: start,
8221
+ end: start + panel.children.length - 1,
8222
+ element: panel
8223
+ }]);
8224
+ }, []);
8225
+ };
8226
+ __proto._getSideStateFromCrossStructure = function (panels) {
8227
+ var groupPanels = this._getGroupFromAttribute(panels);
8228
+ return this._getSideStateFromGroup(groupPanels);
8229
+ };
8183
8230
  __proto._createSideFlicking = function () {
8184
8231
  var _this = this;
8185
8232
  return this.sideState.map(function (state, i) {
@@ -8190,20 +8237,6 @@ var CrossFlicking = /*#__PURE__*/function (_super) {
8190
8237
  }));
8191
8238
  });
8192
8239
  };
8193
- __proto._syncToCategory = function (index, outerIndex) {
8194
- var _this = this;
8195
- this.stopAnimation();
8196
- this._sideFlicking.forEach(function (child, i) {
8197
- var _a = _this._sideState[i],
8198
- start = _a.start,
8199
- end = _a.end;
8200
- if (start <= index && end >= index && outerIndex !== i) {
8201
- child.stopAnimation();
8202
- void child.moveTo(index, 0);
8203
- void _this.moveTo(i, 0);
8204
- }
8205
- });
8206
- };
8207
8240
  return CrossFlicking;
8208
8241
  }(Flicking);
8209
8242
 
@@ -8424,6 +8457,7 @@ var parseAlign = function (alignVal) {
8424
8457
  var modules = {
8425
8458
  __proto__: null,
8426
8459
  'default': Flicking,
8460
+ SIDE_EVENTS: SIDE_EVENTS,
8427
8461
  CrossFlicking: CrossFlicking,
8428
8462
  VanillaElementProvider: VanillaElementProvider,
8429
8463
  VirtualElementProvider: VirtualElementProvider,
@@ -8537,6 +8571,7 @@ exports.NormalRenderingStrategy = NormalRenderingStrategy;
8537
8571
  exports.ORDER = ORDER;
8538
8572
  exports.Panel = Panel;
8539
8573
  exports.Renderer = Renderer;
8574
+ exports.SIDE_EVENTS = SIDE_EVENTS;
8540
8575
  exports.SnapControl = SnapControl;
8541
8576
  exports.State = State;
8542
8577
  exports.StateMachine = StateMachine;