@egjs/flicking 4.12.0-beta.1 → 4.12.0-beta.11

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.css CHANGED
@@ -15,8 +15,8 @@
15
15
  display: inline-flex;
16
16
  -webkit-box-orient: vertical;
17
17
  -webkit-box-direction: normal;
18
- -ms-flex-direction: column;
19
- flex-direction: column;
18
+ -ms-flex-direction: column;
19
+ flex-direction: column;
20
20
  }
21
21
 
22
22
  .flicking-viewport.flicking-hidden > .flicking-camera > * {
@@ -32,13 +32,13 @@
32
32
  position: relative;
33
33
  -webkit-box-orient: horizontal;
34
34
  -webkit-box-direction: normal;
35
- -ms-flex-direction: row;
36
- flex-direction: row;
35
+ -ms-flex-direction: row;
36
+ flex-direction: row;
37
37
  z-index: 1;
38
38
  will-change: transform;
39
39
  }
40
40
 
41
41
  .flicking-camera > * {
42
42
  -ms-flex-negative: 0;
43
- flex-shrink: 0;
43
+ flex-shrink: 0;
44
44
  }
@@ -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.1
7
+ version: 4.12.0-beta.11
8
8
  */
9
9
  import Component, { ComponentEvent } from '@egjs/component';
10
10
  import Axes, { PanInput } from '@egjs/axes';
@@ -385,6 +385,8 @@ var MOVE_TYPE = {
385
385
  STRICT: "strict"
386
386
  };
387
387
  var CLASS = {
388
+ VIEWPORT: "flicking-viewport",
389
+ CAMERA: "flicking-camera",
388
390
  VERTICAL: "vertical",
389
391
  HIDDEN: "flicking-hidden",
390
392
  DEFAULT_VIRTUAL: "flicking-panel"
@@ -736,6 +738,26 @@ var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
736
738
  obj.__proto__ = proto;
737
739
  return obj;
738
740
  };
741
+ var camelize = function (str) {
742
+ return str.replace(/[\s-_]([a-z])/g, function (all, letter) {
743
+ return letter.toUpperCase();
744
+ });
745
+ };
746
+ var getDataAttributes = function (element, attributePrefix) {
747
+ var dataAttributes = {};
748
+ var attributes = element.attributes;
749
+ var length = attributes.length;
750
+ for (var i = 0; i < length; ++i) {
751
+ var attribute = attributes[i];
752
+ var name_1 = attribute.name,
753
+ value = attribute.value;
754
+ if (name_1.indexOf(attributePrefix) === -1) {
755
+ continue;
756
+ }
757
+ dataAttributes[camelize(name_1.replace(attributePrefix, ""))] = value;
758
+ }
759
+ return dataAttributes;
760
+ };
739
761
 
740
762
  /*
741
763
  * Copyright (c) 2015 NAVER Corp.
@@ -1568,6 +1590,9 @@ var HoldingState = /*#__PURE__*/function (_super) {
1568
1590
  axesEvent = ctx.axesEvent,
1569
1591
  transitTo = ctx.transitTo;
1570
1592
  var inputEvent = axesEvent.inputEvent;
1593
+ if (!inputEvent) {
1594
+ return;
1595
+ }
1571
1596
  var offset = flicking.horizontal ? inputEvent.offsetX : inputEvent.offsetY;
1572
1597
  var moveStartEvent = new ComponentEvent(EVENTS.MOVE_START, {
1573
1598
  isTrusted: axesEvent.isTrusted,
@@ -3722,6 +3747,7 @@ var Camera = /*#__PURE__*/function () {
3722
3747
  var _this = this;
3723
3748
  var _b = (_a === void 0 ? {} : _a).align,
3724
3749
  align = _b === void 0 ? ALIGN.CENTER : _b;
3750
+ this._lookedOffset = 0;
3725
3751
  this._checkTranslateSupport = function () {
3726
3752
  var e_1, _a;
3727
3753
  var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
@@ -4081,6 +4107,8 @@ var Camera = /*#__PURE__*/function () {
4081
4107
  */
4082
4108
  __proto.lookAt = function (pos) {
4083
4109
  var _this = this;
4110
+ var prevOffset = this._offset;
4111
+ var isChangedOffset = this._lookedOffset !== prevOffset;
4084
4112
  var flicking = getFlickingAttached(this._flicking);
4085
4113
  var prevPos = this._position;
4086
4114
  this._position = pos;
@@ -4091,7 +4119,12 @@ var Camera = /*#__PURE__*/function () {
4091
4119
  if (toggled) {
4092
4120
  void flicking.renderer.render().then(function () {
4093
4121
  _this.updateOffset();
4122
+ _this._lookedOffset = _this._offset;
4094
4123
  });
4124
+ } else if (isChangedOffset) {
4125
+ // sync offset for renderOnlyVisible on resize
4126
+ this.updateOffset();
4127
+ this._lookedOffset = this._offset;
4095
4128
  } else {
4096
4129
  this.applyTransform();
4097
4130
  }
@@ -4266,8 +4299,8 @@ var Camera = /*#__PURE__*/function () {
4266
4299
  return this;
4267
4300
  };
4268
4301
  /**
4269
- * Update Viewport's height to active panel's height
4270
- * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4302
+ * Update Viewport's height to visible panel's max height
4303
+ * @ko 현재 활성화된 패널과 보이는 패널의 최대 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4271
4304
  * @throws {FlickingError}
4272
4305
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4273
4306
  * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
@@ -4277,9 +4310,17 @@ var Camera = /*#__PURE__*/function () {
4277
4310
  __proto.updateAdaptiveHeight = function () {
4278
4311
  var flicking = getFlickingAttached(this._flicking);
4279
4312
  var activePanel = flicking.control.activePanel;
4280
- if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
4313
+ var visiblePanels = flicking.visiblePanels;
4314
+ var selectedPanels = __spread(visiblePanels);
4315
+ if (activePanel) {
4316
+ selectedPanels.push(activePanel);
4317
+ }
4318
+ if (!flicking.horizontal || !flicking.adaptive || !selectedPanels.length) return;
4319
+ var maxHeight = Math.max.apply(Math, __spread(selectedPanels.map(function (panel) {
4320
+ return panel.height;
4321
+ })));
4281
4322
  flicking.viewport.setSize({
4282
- height: activePanel.height
4323
+ height: maxHeight
4283
4324
  });
4284
4325
  };
4285
4326
  /**
@@ -4350,6 +4391,7 @@ var Camera = /*#__PURE__*/function () {
4350
4391
  };
4351
4392
  __proto._resetInternalValues = function () {
4352
4393
  this._position = 0;
4394
+ this._lookedOffset = 0;
4353
4395
  this._alignPos = 0;
4354
4396
  this._offset = 0;
4355
4397
  this._circularOffset = 0;
@@ -5410,6 +5452,9 @@ var Panel = /*#__PURE__*/function () {
5410
5452
  var flicking = this._flicking;
5411
5453
  var horizontal = flicking.horizontal,
5412
5454
  useFractionalSize = flicking.useFractionalSize;
5455
+ if (!el) {
5456
+ return this;
5457
+ }
5413
5458
  if (cached) {
5414
5459
  this._size = cached.size;
5415
5460
  this._margin = __assign({}, cached.margin);
@@ -7871,180 +7916,334 @@ var Flicking = /*#__PURE__*/function (_super) {
7871
7916
  * Flicking.VERSION; // ex) 4.0.0
7872
7917
  * ```
7873
7918
  */
7874
- Flicking.VERSION = "4.12.0-beta.1";
7919
+ Flicking.VERSION = "4.12.0-beta.11";
7875
7920
  return Flicking;
7876
7921
  }(Component);
7877
7922
 
7878
- /*
7879
- * Copyright (c) 2015 NAVER Corp.
7880
- * egjs projects are licensed under the MIT license
7881
- */
7882
- /**
7883
- * @extends Component
7884
- * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
7885
- * @requires {@link https://github.com/naver/egjs-component|@egjs/component}
7886
- * @requires {@link https://github.com/naver/egjs-axes|@egjs/axes}
7887
- */
7923
+ var SIDE_EVENTS = {
7924
+ HOLD_START: "sideHoldStart",
7925
+ HOLD_END: "sideHoldEnd",
7926
+ MOVE_START: "sideMoveStart",
7927
+ MOVE: "sideMove",
7928
+ MOVE_END: "sideMoveEnd",
7929
+ WILL_CHANGE: "sideWillChange",
7930
+ CHANGED: "sideChanged",
7931
+ WILL_RESTORE: "sideWillRestore",
7932
+ RESTORED: "sideRestored"
7933
+ };
7888
7934
  var CrossFlicking = /*#__PURE__*/function (_super) {
7889
7935
  __extends(CrossFlicking, _super);
7890
- // Options Setter
7891
- // UI / LAYOUT
7892
- // public set align(val: FlickingOptions["align"]) {
7893
- // this._align = val;
7894
- // }
7895
- function CrossFlicking(root, _a) {
7896
- var _b = (_a === void 0 ? {} : _a).verticalOptions,
7897
- verticalOptions = _b === void 0 ? undefined : _b;
7898
- var _this = _super.call(this, root) || this;
7936
+ function CrossFlicking(root, options) {
7937
+ var _this = _super.call(this, root, options) || this;
7938
+ _this._syncToCategory = function (index, outerIndex) {
7939
+ if (_this._disableIndexSync) {
7940
+ return;
7941
+ }
7942
+ _this.stopAnimation();
7943
+ _this._sideFlicking.forEach(function (child, i) {
7944
+ var _a = _this._sideState[i],
7945
+ start = _a.start,
7946
+ end = _a.end;
7947
+ if (start <= index && end >= index && outerIndex !== i) {
7948
+ child.stopAnimation();
7949
+ void child.moveTo(index, 0);
7950
+ void _this.moveTo(i, 0);
7951
+ }
7952
+ });
7953
+ };
7954
+ _this._setDraggable = function (direction, draggable) {
7955
+ if (!_this._disableSlideOnHold) {
7956
+ return;
7957
+ }
7958
+ var dragThreshold = _this._originalDragThreshold;
7959
+ var threshold = draggable ? dragThreshold && dragThreshold >= 10 ? dragThreshold : 10 : Infinity;
7960
+ if (direction === MOVE_DIRECTION.HORIZONTAL === _this.horizontal) {
7961
+ _this.dragThreshold = threshold;
7962
+ } else if (direction === MOVE_DIRECTION.VERTICAL === _this.horizontal) {
7963
+ _this._sideFlicking.forEach(function (child) {
7964
+ child.dragThreshold = threshold;
7965
+ });
7966
+ }
7967
+ };
7968
+ _this._setPreviousSideIndex = function () {
7969
+ _this._sideFlicking.forEach(function (child, i) {
7970
+ var _a = _this._sideState[i],
7971
+ start = _a.start,
7972
+ end = _a.end;
7973
+ if (_this._preserveIndex) {
7974
+ if (_this._nextIndex !== i) {
7975
+ if (child.index < start) {
7976
+ child.stopAnimation();
7977
+ void child.moveTo(start, 0);
7978
+ } else if (child.index > end) {
7979
+ child.stopAnimation();
7980
+ void child.moveTo(end, 0);
7981
+ }
7982
+ }
7983
+ } else {
7984
+ if (_this._nextIndex !== i) {
7985
+ void child.moveTo(start, 0);
7986
+ }
7987
+ }
7988
+ });
7989
+ };
7899
7990
  _this._onHorizontalHoldStart = function () {
7900
- _this.dragThreshold = 10;
7991
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
7901
7992
  _this._moveDirection = null;
7902
7993
  };
7903
7994
  _this._onHorizontalMove = function (e) {
7904
7995
  if (e.isTrusted && !_this._moveDirection) {
7905
- _this._verticalFlicking.forEach(function (child) {
7906
- child.dragThreshold = Infinity;
7907
- });
7996
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, false);
7908
7997
  _this._moveDirection = MOVE_DIRECTION.HORIZONTAL;
7909
7998
  }
7910
7999
  };
7911
8000
  _this._onHorizontalMoveEnd = function (e) {
7912
8001
  var visiblePanels = _this.visiblePanels;
7913
- _this._verticalFlicking.forEach(function (child) {
7914
- child.dragThreshold = 10;
7915
- });
7916
- _this._moveDirection = null;
7917
8002
  if (visiblePanels.length > 1) {
7918
8003
  _this._nextIndex = e.direction === "NEXT" ? visiblePanels[1].index : visiblePanels[0].index;
7919
8004
  } else {
7920
8005
  _this._nextIndex = visiblePanels[0].index;
7921
8006
  }
7922
- _this._verticalFlicking.forEach(function (child, i) {
7923
- if (_this._nextIndex !== i) {
7924
- var _a = _this._verticalState[i],
7925
- start = _a.start,
7926
- end = _a.end;
7927
- if (child.index < start) {
7928
- child.stopAnimation();
7929
- void child.moveTo(start, 0);
7930
- } else if (child.index > end) {
7931
- child.stopAnimation();
7932
- void child.moveTo(end, 0);
7933
- }
7934
- }
8007
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
8008
+ _this._moveDirection = null;
8009
+ // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 requestAnimationFrame 처리
8010
+ requestAnimationFrame(function () {
8011
+ return _this._setPreviousSideIndex();
7935
8012
  });
7936
8013
  if (e.isTrusted) {
7937
- _this._syncToCategory(_this._verticalFlicking[_this._nextIndex].index, _this._nextIndex);
8014
+ _this._syncToCategory(_this._sideFlicking[_this._nextIndex].index, _this._nextIndex);
7938
8015
  }
7939
8016
  };
7940
- _this._onVerticalHoldStart = function () {
7941
- _this._verticalFlicking.forEach(function (child) {
7942
- child.dragThreshold = 10;
7943
- });
8017
+ _this._onSideHoldStart = function () {
8018
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
7944
8019
  _this._moveDirection = null;
7945
8020
  };
7946
- _this._onVerticalMove = function (e) {
8021
+ _this._onSideMove = function (e) {
7947
8022
  if (e.isTrusted && !_this._moveDirection) {
7948
- _this.dragThreshold = Infinity;
8023
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, false);
7949
8024
  _this._moveDirection = MOVE_DIRECTION.VERTICAL;
7950
8025
  }
7951
8026
  };
7952
- _this._onVerticalMoveEnd = function () {
7953
- _this.dragThreshold = 10;
8027
+ _this._onSideMoveEnd = function () {
8028
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
7954
8029
  _this._moveDirection = null;
7955
8030
  };
7956
- _this._onVerticalChanged = function (e) {
7957
- // this.visiblePanels.length 2보다 크다면 가로 방향 Flicking이 조작 중이라는 것을 의미합니다.
7958
- // 경우 가로 방향 Flicking의 이동이 완전히 끝난 _onHorizontalMoveEnd 에서 syncToCategory할 것이므로 여기서는 하지 않습니다.
7959
- if (_this.visiblePanels.length < 2 && _this._verticalFlicking[_this.index] === e.currentTarget) {
8031
+ _this._onSideChanged = function (e) {
8032
+ // If this.visiblePanels.length >= 2, it means that horizontal flicking is being dragged.
8033
+ // In this case, syncToCategory in _onHorizontalMoveEnd will fire after moving finishes, so we don't fire it here.
8034
+ if (_this.visiblePanels.length < 2 && _this._sideFlicking[_this.index] === e.currentTarget) {
7960
8035
  _this._syncToCategory(e.index, _this.index);
7961
8036
  }
7962
8037
  };
8038
+ var _a = options.sideOptions,
8039
+ sideOptions = _a === void 0 ? {} : _a,
8040
+ _b = options.preserveIndex,
8041
+ preserveIndex = _b === void 0 ? true : _b,
8042
+ _c = options.disableSlideOnHold,
8043
+ disableSlideOnHold = _c === void 0 ? true : _c,
8044
+ _d = options.disableIndexSync,
8045
+ disableIndexSync = _d === void 0 ? false : _d;
7963
8046
  // Internal states
7964
- _this._verticalState = [];
7965
8047
  _this._moveDirection = null;
7966
8048
  _this._nextIndex = 0;
8049
+ _this._originalDragThreshold = _this.dragThreshold;
7967
8050
  // Bind options
7968
- _this._verticalOptions = verticalOptions;
8051
+ _this._sideOptions = sideOptions;
8052
+ _this._preserveIndex = preserveIndex;
8053
+ _this._disableSlideOnHold = disableSlideOnHold;
8054
+ _this._disableIndexSync = disableIndexSync;
7969
8055
  return _this;
7970
- // Create core components
7971
- // this._viewport = new Viewport(this, getElement(root));
7972
8056
  }
7973
8057
  var __proto = CrossFlicking.prototype;
7974
- Object.defineProperty(__proto, "verticalOptions", {
8058
+ Object.defineProperty(__proto, "sideFlicking", {
7975
8059
  // Components
7976
- /**
7977
- * Change active panel index on mouse/touch hold while animating.
7978
- * `index` of the `willChange`/`willRestore` event will be used as new index.
7979
- * @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
7980
- * `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
7981
- * @type {FlickingOptions}
7982
- * @default undefined
7983
- * @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
7984
- */
7985
8060
  get: function () {
7986
- return this._verticalOptions;
8061
+ return this._sideFlicking;
8062
+ },
8063
+ enumerable: false,
8064
+ configurable: true
8065
+ });
8066
+ Object.defineProperty(__proto, "sideState", {
8067
+ get: function () {
8068
+ return this._sideState;
8069
+ },
8070
+ enumerable: false,
8071
+ configurable: true
8072
+ });
8073
+ Object.defineProperty(__proto, "sideOptions", {
8074
+ // Options Getter
8075
+ get: function () {
8076
+ return this._sideOptions;
8077
+ },
8078
+ // Options Setter
8079
+ set: function (val) {
8080
+ this._sideOptions = val;
8081
+ },
8082
+ enumerable: false,
8083
+ configurable: true
8084
+ });
8085
+ Object.defineProperty(__proto, "preserveIndex", {
8086
+ get: function () {
8087
+ return this._preserveIndex;
8088
+ },
8089
+ set: function (val) {
8090
+ this._preserveIndex = val;
8091
+ },
8092
+ enumerable: false,
8093
+ configurable: true
8094
+ });
8095
+ Object.defineProperty(__proto, "disableSlideOnHold", {
8096
+ get: function () {
8097
+ return this._disableSlideOnHold;
8098
+ },
8099
+ set: function (val) {
8100
+ this._disableSlideOnHold = val;
8101
+ },
8102
+ enumerable: false,
8103
+ configurable: true
8104
+ });
8105
+ Object.defineProperty(__proto, "disableIndexSync", {
8106
+ get: function () {
8107
+ return this._disableIndexSync;
8108
+ },
8109
+ set: function (val) {
8110
+ this._disableIndexSync = val;
7987
8111
  },
7988
8112
  enumerable: false,
7989
8113
  configurable: true
7990
8114
  });
7991
- /**
7992
- * Initialize Flicking and move to the default index
7993
- * This is automatically called on Flicking's constructor when `autoInit` is true(default)
7994
- * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
7995
- * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
7996
- * @fires Flicking#ready
7997
- * @return {Promise<void>}
7998
- */
7999
8115
  __proto.init = function () {
8000
8116
  var _this = this;
8001
8117
  return _super.prototype.init.call(this).then(function () {
8002
- // data-index로 분류하기 전에 임시로 모든 children에 대해 vertical flicking으로 해보자.
8003
- // camera.children들에 대해 갯수 세기
8004
- var verticalPanels = "";
8005
- _this._verticalState = _this.camera.children.reduce(function (state, child) {
8006
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
8007
- verticalPanels += child.children[0].innerHTML;
8008
- return __spread(state, [{
8009
- start: start,
8010
- end: start + child.children[0].children.length - 1,
8011
- element: child
8012
- }]);
8013
- }, []);
8014
- _this.camera.children.forEach(function (child) {
8015
- child.children[0].innerHTML = verticalPanels;
8118
+ _this._sideState = _this._createSideState();
8119
+ _this._sideFlicking = _this._createSideFlicking();
8120
+ _this._addComponentEvents();
8121
+ });
8122
+ };
8123
+ __proto.destroy = function () {
8124
+ this._sideFlicking.forEach(function (flicking) {
8125
+ flicking.destroy();
8126
+ });
8127
+ _super.prototype.destroy.call(this);
8128
+ };
8129
+ __proto._addComponentEvents = function () {
8130
+ var _this = this;
8131
+ this.on(EVENTS.HOLD_START, this._onHorizontalHoldStart);
8132
+ this.on(EVENTS.MOVE, this._onHorizontalMove);
8133
+ this.on(EVENTS.MOVE_END, this._onHorizontalMoveEnd);
8134
+ this._sideFlicking.forEach(function (flicking, mainIndex) {
8135
+ flicking.on(EVENTS.HOLD_START, _this._onSideHoldStart);
8136
+ flicking.on(EVENTS.MOVE, _this._onSideMove);
8137
+ flicking.on(EVENTS.MOVE_END, _this._onSideMoveEnd);
8138
+ flicking.on(EVENTS.CHANGED, _this._onSideChanged);
8139
+ Object.keys(SIDE_EVENTS).forEach(function (name) {
8140
+ flicking.on(EVENTS[name], function (event) {
8141
+ _this.trigger(new ComponentEvent(SIDE_EVENTS[name], __assign({
8142
+ mainIndex: mainIndex
8143
+ }, event)));
8144
+ });
8016
8145
  });
8017
- _this._verticalFlicking = _this.camera.children.map(function (child, i) {
8018
- return new Flicking(child, __assign(__assign({}, _this.verticalOptions), {
8019
- horizontal: false,
8020
- panelsPerView: 1,
8021
- defaultIndex: _this._verticalState[i].start
8022
- }));
8146
+ });
8147
+ };
8148
+ __proto._createSideState = function () {
8149
+ var viewportEl = this.element;
8150
+ var cameraEl = this.camera.element;
8151
+ var panels = toArray(cameraEl.children);
8152
+ var isCrossStructure = getDataAttributes(viewportEl, "data-cross-").structure;
8153
+ var sideState = [];
8154
+ if (!isCrossStructure) {
8155
+ var groupPanels = this._getGroupFromAttribute(panels);
8156
+ var groupKeys = Object.keys(groupPanels);
8157
+ if (groupKeys.length) {
8158
+ sideState = this._getSideStateFromGroup(groupPanels);
8159
+ this.remove(0, this.panelCount - groupKeys.length);
8160
+ } else {
8161
+ sideState = this._getSideStateFromPanels(panels);
8162
+ }
8163
+ this._createCrossStructure(sideState);
8164
+ } else {
8165
+ sideState = this._getSideStateFromCrossStructure(panels);
8166
+ }
8167
+ void this.resize();
8168
+ return sideState;
8169
+ };
8170
+ __proto._createCrossStructure = function (sideState) {
8171
+ var _this = this;
8172
+ var sideCamera = document.createElement("div");
8173
+ var sidePanels = "";
8174
+ sideCamera.classList.add(CLASS.CAMERA);
8175
+ sideState.forEach(function (state, i) {
8176
+ var panel = _this.camera.children[i];
8177
+ sidePanels += state.element.innerHTML;
8178
+ Array.from(panel.attributes).forEach(function (attribute) {
8179
+ return panel.removeAttribute(attribute.name);
8023
8180
  });
8024
- _this.on(EVENTS.HOLD_START, _this._onHorizontalHoldStart);
8025
- _this.on(EVENTS.MOVE, _this._onHorizontalMove);
8026
- _this.on(EVENTS.MOVE_END, _this._onHorizontalMoveEnd);
8027
- _this._verticalFlicking.forEach(function (child) {
8028
- child.on(EVENTS.HOLD_START, _this._onVerticalHoldStart);
8029
- child.on(EVENTS.MOVE, _this._onVerticalMove);
8030
- child.on(EVENTS.MOVE_END, _this._onVerticalMoveEnd);
8031
- child.on(EVENTS.CHANGED, _this._onVerticalChanged);
8181
+ });
8182
+ sideCamera.innerHTML = sidePanels;
8183
+ sideState.forEach(function (_, i) {
8184
+ var panel = _this.camera.children[i];
8185
+ [CLASS.VIEWPORT, CLASS.VERTICAL].forEach(function (className) {
8186
+ if (!panel.classList.contains(className)) {
8187
+ panel.classList.add(className);
8188
+ }
8032
8189
  });
8190
+ panel.innerHTML = sideCamera.outerHTML;
8033
8191
  });
8192
+ this.element.setAttribute("data-cross-structure", "true");
8034
8193
  };
8035
- __proto._syncToCategory = function (index, outerIndex) {
8036
- var _this = this;
8037
- this.stopAnimation();
8038
- this._verticalFlicking.forEach(function (child, i) {
8039
- var _a = _this._verticalState[i],
8040
- start = _a.start,
8041
- end = _a.end;
8042
- if (start <= index && end >= index && outerIndex !== i) {
8043
- child.stopAnimation();
8044
- void child.moveTo(index, 0);
8045
- void _this.moveTo(i, 0);
8194
+ __proto._getGroupFromAttribute = function (panels) {
8195
+ var groupKeys = [];
8196
+ var groupPanels = {};
8197
+ panels.forEach(function (panel) {
8198
+ var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8199
+ if (groupKey && !includes(groupKeys, groupKey)) {
8200
+ groupKeys.push(groupKey);
8201
+ groupPanels[groupKey] = [panel];
8202
+ } else if (groupKey) {
8203
+ groupPanels[groupKey].push(panel);
8046
8204
  }
8047
8205
  });
8206
+ return groupPanels;
8207
+ };
8208
+ __proto._getSideStateFromGroup = function (groupPanels) {
8209
+ return Object.keys(groupPanels).reduce(function (state, key) {
8210
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
8211
+ var element = groupPanels[key].reduce(function (el, panel) {
8212
+ el.innerHTML += panel.outerHTML;
8213
+ return el;
8214
+ }, document.createElement("div"));
8215
+ return __spread(state, [{
8216
+ key: key,
8217
+ start: start,
8218
+ end: start + groupPanels[key].length - 1,
8219
+ element: element
8220
+ }]);
8221
+ }, []);
8222
+ };
8223
+ __proto._getSideStateFromPanels = function (panels) {
8224
+ return panels.reduce(function (state, panel, i) {
8225
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
8226
+ return __spread(state, [{
8227
+ key: i.toString(),
8228
+ start: start,
8229
+ end: start + panel.children.length - 1,
8230
+ element: panel
8231
+ }]);
8232
+ }, []);
8233
+ };
8234
+ __proto._getSideStateFromCrossStructure = function (panels) {
8235
+ var groupPanels = this._getGroupFromAttribute(panels);
8236
+ return this._getSideStateFromGroup(groupPanels);
8237
+ };
8238
+ __proto._createSideFlicking = function () {
8239
+ var _this = this;
8240
+ return this.sideState.map(function (state, i) {
8241
+ return new Flicking(_this.camera.children[i], __assign(__assign({}, _this.sideOptions), {
8242
+ horizontal: false,
8243
+ panelsPerView: 1,
8244
+ defaultIndex: state.start
8245
+ }));
8246
+ });
8048
8247
  };
8049
8248
  return CrossFlicking;
8050
8249
  }(Flicking);
@@ -8263,5 +8462,5 @@ var parseAlign = function (alignVal) {
8263
8462
  * egjs projects are licensed under the MIT license
8264
8463
  */
8265
8464
 
8266
- export { ALIGN, AnchorPoint, AnimatingState, AxesController, BoundCameraMode, CIRCULAR_FALLBACK, CLASS, Camera, CircularCameraMode, Control, CrossFlicking, DIRECTION, DisabledState, DraggingState, CODE as ERROR_CODE, EVENTS, ExternalRenderer, FlickingError, FreeControl, HoldingState, IdleState, LinearCameraMode, MOVE_DIRECTION, MOVE_TYPE, NormalRenderingStrategy, ORDER, Panel, Renderer, SnapControl, State, StateMachine, StrictControl, VanillaElementProvider, VanillaRenderer, Viewport, VirtualElementProvider, VirtualManager, VirtualPanel, VirtualRenderingStrategy, checkExistence, circulateIndex, circulatePosition, clamp, Flicking as default, find, findIndex, findRight, getDefaultCameraTransform, getDirection, getElement, getElementSize, getFlickingAttached, getMinusCompensatedIndex, getProgress, getRenderingPanels, getStyle, includes, isBetween, isString, merge, parseAlign$1 as parseAlign, parseArithmeticExpression, parseArithmeticSize, parseBounce, parseCSSSizeValue, parseElement, parsePanelAlign, range, setPrototypeOf, setSize, sync, toArray, withFlickingMethods };
8465
+ export { ALIGN, AnchorPoint, AnimatingState, AxesController, BoundCameraMode, CIRCULAR_FALLBACK, CLASS, Camera, CircularCameraMode, Control, CrossFlicking, DIRECTION, DisabledState, DraggingState, CODE as ERROR_CODE, EVENTS, ExternalRenderer, FlickingError, FreeControl, HoldingState, IdleState, LinearCameraMode, MOVE_DIRECTION, MOVE_TYPE, NormalRenderingStrategy, ORDER, Panel, Renderer, SIDE_EVENTS, SnapControl, State, StateMachine, StrictControl, VanillaElementProvider, VanillaRenderer, Viewport, VirtualElementProvider, VirtualManager, VirtualPanel, VirtualRenderingStrategy, camelize, checkExistence, circulateIndex, circulatePosition, clamp, Flicking as default, find, findIndex, findRight, getDataAttributes, getDefaultCameraTransform, getDirection, getElement, getElementSize, getFlickingAttached, getMinusCompensatedIndex, getProgress, getRenderingPanels, getStyle, includes, isBetween, isString, merge, parseAlign$1 as parseAlign, parseArithmeticExpression, parseArithmeticSize, parseBounce, parseCSSSizeValue, parseElement, parsePanelAlign, range, setPrototypeOf, setSize, sync, toArray, withFlickingMethods };
8267
8466
  //# sourceMappingURL=flicking.esm.js.map