@egjs/flicking 4.12.0-beta.8 → 4.12.0

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.
Files changed (85) hide show
  1. package/declaration/CrossFlicking.d.ts +89 -52
  2. package/declaration/Flicking.d.ts +244 -244
  3. package/declaration/camera/Camera.d.ts +90 -89
  4. package/declaration/camera/index.d.ts +4 -4
  5. package/declaration/camera/mode/BoundCameraMode.d.ts +13 -13
  6. package/declaration/camera/mode/CameraMode.d.ts +20 -20
  7. package/declaration/camera/mode/CircularCameraMode.d.ts +19 -19
  8. package/declaration/camera/mode/LinearCameraMode.d.ts +9 -9
  9. package/declaration/camera/mode/index.d.ts +6 -6
  10. package/declaration/cfc/getDefaultCameraTransform.d.ts +3 -3
  11. package/declaration/cfc/getRenderingPanels.d.ts +4 -4
  12. package/declaration/cfc/index.d.ts +5 -5
  13. package/declaration/cfc/sync.d.ts +4 -4
  14. package/declaration/cfc/withFlickingMethods.d.ts +2 -2
  15. package/declaration/const/axes.d.ts +8 -8
  16. package/declaration/const/error.d.ts +34 -34
  17. package/declaration/const/external.d.ts +54 -54
  18. package/declaration/control/AxesController.d.ts +44 -44
  19. package/declaration/control/Control.d.ts +45 -45
  20. package/declaration/control/FreeControl.d.ts +14 -14
  21. package/declaration/control/SnapControl.d.ts +16 -16
  22. package/declaration/control/StateMachine.d.ts +14 -14
  23. package/declaration/control/StrictControl.d.ts +20 -20
  24. package/declaration/control/index.d.ts +14 -14
  25. package/declaration/control/states/AnimatingState.d.ts +9 -9
  26. package/declaration/control/states/DisabledState.d.ts +9 -9
  27. package/declaration/control/states/DraggingState.d.ts +8 -8
  28. package/declaration/control/states/HoldingState.d.ts +10 -10
  29. package/declaration/control/states/IdleState.d.ts +9 -9
  30. package/declaration/control/states/State.d.ts +47 -47
  31. package/declaration/core/AnchorPoint.d.ts +15 -15
  32. package/declaration/core/AutoResizer.d.ts +16 -16
  33. package/declaration/core/FlickingError.d.ts +5 -5
  34. package/declaration/core/ResizeWatcher.d.ts +33 -33
  35. package/declaration/core/Viewport.d.ts +25 -25
  36. package/declaration/core/VirtualManager.d.ts +37 -37
  37. package/declaration/core/index.d.ts +6 -6
  38. package/declaration/core/panel/Panel.d.ts +89 -89
  39. package/declaration/core/panel/VirtualPanel.d.ts +19 -19
  40. package/declaration/core/panel/index.d.ts +5 -5
  41. package/declaration/core/panel/provider/ElementProvider.d.ts +8 -8
  42. package/declaration/core/panel/provider/VanillaElementProvider.d.ts +12 -12
  43. package/declaration/core/panel/provider/VirtualElementProvider.d.ts +15 -15
  44. package/declaration/core/panel/provider/index.d.ts +5 -5
  45. package/declaration/index.cjs.d.ts +3 -3
  46. package/declaration/index.d.ts +15 -15
  47. package/declaration/index.umd.d.ts +2 -2
  48. package/declaration/renderer/ExternalRenderer.d.ts +7 -7
  49. package/declaration/renderer/Renderer.d.ts +59 -59
  50. package/declaration/renderer/VanillaRenderer.d.ts +10 -10
  51. package/declaration/renderer/index.d.ts +6 -6
  52. package/declaration/renderer/strategy/NormalRenderingStrategy.d.ts +23 -23
  53. package/declaration/renderer/strategy/RenderingStrategy.d.ts +15 -15
  54. package/declaration/renderer/strategy/VirtualRenderingStrategy.d.ts +17 -17
  55. package/declaration/renderer/strategy/index.d.ts +5 -5
  56. package/declaration/type/event.d.ts +88 -88
  57. package/declaration/type/external.d.ts +31 -31
  58. package/declaration/type/internal.d.ts +13 -13
  59. package/declaration/utils.d.ts +47 -47
  60. package/dist/flicking-inline.css +37 -0
  61. package/dist/flicking-inline.min.css +1 -0
  62. package/dist/flicking-inline.min.min.css +1 -0
  63. package/dist/flicking.cjs.js +201 -120
  64. package/dist/flicking.cjs.js.map +1 -1
  65. package/dist/flicking.css +40 -0
  66. package/dist/flicking.esm.js +200 -121
  67. package/dist/flicking.esm.js.map +1 -1
  68. package/dist/flicking.js +200 -120
  69. package/dist/flicking.js.map +1 -1
  70. package/dist/flicking.min.css +1 -0
  71. package/dist/flicking.min.js +2 -2
  72. package/dist/flicking.min.js.map +1 -1
  73. package/dist/flicking.min.min.css +1 -0
  74. package/dist/flicking.pkgd.js +950 -870
  75. package/dist/flicking.pkgd.js.map +1 -1
  76. package/dist/flicking.pkgd.min.js +2 -2
  77. package/dist/flicking.pkgd.min.js.map +1 -1
  78. package/package.json +5 -6
  79. package/sass/flicking.sass +13 -0
  80. package/src/CrossFlicking.ts +224 -112
  81. package/src/Flicking.ts +1 -1
  82. package/src/camera/Camera.ts +24 -4
  83. package/src/control/states/HoldingState.ts +4 -0
  84. package/src/core/panel/Panel.ts +4 -0
  85. package/src/utils.ts +4 -0
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.8
7
+ version: 4.12.0
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')) :
@@ -692,6 +692,9 @@ version: 4.12.0-beta.8
692
692
  var setSize = function (el, _a) {
693
693
  var width = _a.width,
694
694
  height = _a.height;
695
+ if (!el) {
696
+ return;
697
+ }
695
698
  if (width != null) {
696
699
  if (isString(width)) {
697
700
  el.style.width = width;
@@ -1640,6 +1643,9 @@ version: 4.12.0-beta.8
1640
1643
  axesEvent = ctx.axesEvent,
1641
1644
  transitTo = ctx.transitTo;
1642
1645
  var inputEvent = axesEvent.inputEvent;
1646
+ if (!inputEvent) {
1647
+ return;
1648
+ }
1643
1649
  var offset = flicking.horizontal ? inputEvent.offsetX : inputEvent.offsetY;
1644
1650
  var moveStartEvent = new Component.ComponentEvent(EVENTS.MOVE_START, {
1645
1651
  isTrusted: axesEvent.isTrusted,
@@ -3815,6 +3821,7 @@ version: 4.12.0-beta.8
3815
3821
  var _this = this;
3816
3822
  var _b = (_a === void 0 ? {} : _a).align,
3817
3823
  align = _b === void 0 ? ALIGN.CENTER : _b;
3824
+ this._lookedOffset = 0;
3818
3825
  this._checkTranslateSupport = function () {
3819
3826
  var e_1, _a;
3820
3827
  var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
@@ -4174,6 +4181,8 @@ version: 4.12.0-beta.8
4174
4181
  */
4175
4182
  __proto.lookAt = function (pos) {
4176
4183
  var _this = this;
4184
+ var prevOffset = this._offset;
4185
+ var isChangedOffset = this._lookedOffset !== prevOffset;
4177
4186
  var flicking = getFlickingAttached(this._flicking);
4178
4187
  var prevPos = this._position;
4179
4188
  this._position = pos;
@@ -4184,7 +4193,12 @@ version: 4.12.0-beta.8
4184
4193
  if (toggled) {
4185
4194
  void flicking.renderer.render().then(function () {
4186
4195
  _this.updateOffset();
4196
+ _this._lookedOffset = _this._offset;
4187
4197
  });
4198
+ } else if (isChangedOffset) {
4199
+ // sync offset for renderOnlyVisible on resize
4200
+ this.updateOffset();
4201
+ this._lookedOffset = this._offset;
4188
4202
  } else {
4189
4203
  this.applyTransform();
4190
4204
  }
@@ -4359,8 +4373,8 @@ version: 4.12.0-beta.8
4359
4373
  return this;
4360
4374
  };
4361
4375
  /**
4362
- * Update Viewport's height to active panel's height
4363
- * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4376
+ * Update Viewport's height to visible panel's max height
4377
+ * @ko 현재 활성화된 패널과 보이는 패널의 최대 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4364
4378
  * @throws {FlickingError}
4365
4379
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4366
4380
  * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
@@ -4370,9 +4384,17 @@ version: 4.12.0-beta.8
4370
4384
  __proto.updateAdaptiveHeight = function () {
4371
4385
  var flicking = getFlickingAttached(this._flicking);
4372
4386
  var activePanel = flicking.control.activePanel;
4373
- if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
4387
+ var visiblePanels = flicking.visiblePanels;
4388
+ var selectedPanels = __spread(visiblePanels);
4389
+ if (activePanel) {
4390
+ selectedPanels.push(activePanel);
4391
+ }
4392
+ if (!flicking.horizontal || !flicking.adaptive || !selectedPanels.length) return;
4393
+ var maxHeight = Math.max.apply(Math, __spread(selectedPanels.map(function (panel) {
4394
+ return panel.height;
4395
+ })));
4374
4396
  flicking.viewport.setSize({
4375
- height: activePanel.height
4397
+ height: maxHeight
4376
4398
  });
4377
4399
  };
4378
4400
  /**
@@ -4443,6 +4465,7 @@ version: 4.12.0-beta.8
4443
4465
  };
4444
4466
  __proto._resetInternalValues = function () {
4445
4467
  this._position = 0;
4468
+ this._lookedOffset = 0;
4446
4469
  this._alignPos = 0;
4447
4470
  this._offset = 0;
4448
4471
  this._circularOffset = 0;
@@ -5516,6 +5539,9 @@ version: 4.12.0-beta.8
5516
5539
  var flicking = this._flicking;
5517
5540
  var horizontal = flicking.horizontal,
5518
5541
  useFractionalSize = flicking.useFractionalSize;
5542
+ if (!el) {
5543
+ return this;
5544
+ }
5519
5545
  if (cached) {
5520
5546
  this._size = cached.size;
5521
5547
  this._margin = __assign({}, cached.margin);
@@ -7937,7 +7963,7 @@ version: 4.12.0-beta.8
7937
7963
  var defaultPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
7938
7964
  if (!defaultPanel) return;
7939
7965
  var nearestAnchor = camera.findNearestAnchor(defaultPanel.position);
7940
- var initialPanel = nearestAnchor && defaultPanel.index !== nearestAnchor.panel.index ? nearestAnchor.panel : defaultPanel;
7966
+ var initialPanel = nearestAnchor && defaultPanel.position !== nearestAnchor.panel.position && defaultPanel.index !== nearestAnchor.panel.index ? nearestAnchor.panel : defaultPanel;
7941
7967
  control.setActive(initialPanel, null, false);
7942
7968
  if (!nearestAnchor) {
7943
7969
  throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(initialPanel.position), CODE.POSITION_NOT_REACHABLE);
@@ -7991,103 +8017,146 @@ version: 4.12.0-beta.8
7991
8017
  * Flicking.VERSION; // ex) 4.0.0
7992
8018
  * ```
7993
8019
  */
7994
- Flicking.VERSION = "4.12.0-beta.8";
8020
+ Flicking.VERSION = "4.12.0";
7995
8021
  return Flicking;
7996
8022
  }(Component);
7997
8023
 
7998
- /*
7999
- * Copyright (c) 2015 NAVER Corp.
8000
- * egjs projects are licensed under the MIT license
8001
- */
8024
+ var SIDE_EVENTS = {
8025
+ HOLD_START: "sideHoldStart",
8026
+ HOLD_END: "sideHoldEnd",
8027
+ MOVE_START: "sideMoveStart",
8028
+ MOVE: "sideMove",
8029
+ MOVE_END: "sideMoveEnd",
8030
+ WILL_CHANGE: "sideWillChange",
8031
+ CHANGED: "sideChanged",
8032
+ WILL_RESTORE: "sideWillRestore",
8033
+ RESTORED: "sideRestored"
8034
+ };
8002
8035
  var CrossFlicking = /*#__PURE__*/function (_super) {
8003
8036
  __extends(CrossFlicking, _super);
8004
8037
  function CrossFlicking(root, options) {
8005
- if (options === void 0) {
8006
- options = {
8007
- sideOptions: {},
8008
- preserveIndex: false,
8009
- disableSlideOnHold: false,
8010
- disableIndexSync: false
8011
- };
8012
- }
8013
8038
  var _this = _super.call(this, root, options) || this;
8039
+ _this._syncToCategory = function (index, outerIndex) {
8040
+ if (_this._disableIndexSync) {
8041
+ return;
8042
+ }
8043
+ _this.stopAnimation();
8044
+ _this._sideFlicking.forEach(function (child, i) {
8045
+ var _a = _this._sideState[i],
8046
+ start = _a.start,
8047
+ end = _a.end;
8048
+ if (start <= index && end >= index && outerIndex !== i) {
8049
+ child.stopAnimation();
8050
+ void child.moveTo(index, 0);
8051
+ void _this.moveTo(i, 0);
8052
+ }
8053
+ });
8054
+ };
8055
+ _this._setDraggable = function (direction, draggable) {
8056
+ if (!_this._disableSlideOnHold) {
8057
+ return;
8058
+ }
8059
+ var dragThreshold = _this._originalDragThreshold;
8060
+ var threshold = draggable ? dragThreshold && dragThreshold >= 10 ? dragThreshold : 10 : Infinity;
8061
+ if (direction === MOVE_DIRECTION.HORIZONTAL === _this.horizontal) {
8062
+ _this.dragThreshold = threshold;
8063
+ } else if (direction === MOVE_DIRECTION.VERTICAL === _this.horizontal) {
8064
+ _this._sideFlicking.forEach(function (child) {
8065
+ child.dragThreshold = threshold;
8066
+ });
8067
+ }
8068
+ };
8069
+ _this._setPreviousSideIndex = function () {
8070
+ _this._sideFlicking.forEach(function (child, i) {
8071
+ var _a = _this._sideState[i],
8072
+ start = _a.start,
8073
+ end = _a.end;
8074
+ if (_this._preserveIndex) {
8075
+ if (_this._nextIndex !== i) {
8076
+ if (child.index < start) {
8077
+ child.stopAnimation();
8078
+ void child.moveTo(start, 0);
8079
+ } else if (child.index > end) {
8080
+ child.stopAnimation();
8081
+ void child.moveTo(end, 0);
8082
+ }
8083
+ }
8084
+ } else {
8085
+ if (_this._nextIndex !== i) {
8086
+ void child.moveTo(start, 0);
8087
+ }
8088
+ }
8089
+ });
8090
+ };
8091
+ _this._addSideIndex = function (e) {
8092
+ e.sideIndex = _this._sideFlicking[e.index].index;
8093
+ };
8014
8094
  _this._onHorizontalHoldStart = function () {
8015
- _this.dragThreshold = 10;
8095
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
8016
8096
  _this._moveDirection = null;
8017
8097
  };
8018
8098
  _this._onHorizontalMove = function (e) {
8019
8099
  if (e.isTrusted && !_this._moveDirection) {
8020
- _this._sideFlicking.forEach(function (child) {
8021
- child.dragThreshold = Infinity;
8022
- });
8100
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, false);
8023
8101
  _this._moveDirection = MOVE_DIRECTION.HORIZONTAL;
8024
8102
  }
8025
8103
  };
8026
8104
  _this._onHorizontalMoveEnd = function (e) {
8027
8105
  var visiblePanels = _this.visiblePanels;
8028
- _this._sideFlicking.forEach(function (child) {
8029
- child.dragThreshold = 10;
8030
- });
8031
- _this._moveDirection = null;
8032
8106
  if (visiblePanels.length > 1) {
8033
8107
  _this._nextIndex = e.direction === "NEXT" ? visiblePanels[1].index : visiblePanels[0].index;
8034
8108
  } else {
8035
8109
  _this._nextIndex = visiblePanels[0].index;
8036
8110
  }
8111
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
8112
+ _this._moveDirection = null;
8037
8113
  // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 requestAnimationFrame 처리
8038
8114
  requestAnimationFrame(function () {
8039
- _this._sideFlicking.forEach(function (child, i) {
8040
- if (_this._nextIndex !== i) {
8041
- var _a = _this._sideState[i],
8042
- start = _a.start,
8043
- end = _a.end;
8044
- if (child.index < start) {
8045
- child.stopAnimation();
8046
- void child.moveTo(start, 0);
8047
- } else if (child.index > end) {
8048
- child.stopAnimation();
8049
- void child.moveTo(end, 0);
8050
- }
8051
- }
8052
- });
8115
+ return _this._setPreviousSideIndex();
8053
8116
  });
8054
8117
  if (e.isTrusted) {
8055
8118
  _this._syncToCategory(_this._sideFlicking[_this._nextIndex].index, _this._nextIndex);
8056
8119
  }
8057
8120
  };
8058
8121
  _this._onSideHoldStart = function () {
8059
- _this._sideFlicking.forEach(function (child) {
8060
- child.dragThreshold = 10;
8061
- });
8122
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
8062
8123
  _this._moveDirection = null;
8063
8124
  };
8064
8125
  _this._onSideMove = function (e) {
8065
8126
  if (e.isTrusted && !_this._moveDirection) {
8066
- _this.dragThreshold = Infinity;
8127
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, false);
8067
8128
  _this._moveDirection = MOVE_DIRECTION.VERTICAL;
8068
8129
  }
8069
8130
  };
8070
8131
  _this._onSideMoveEnd = function () {
8071
- _this.dragThreshold = 10;
8132
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
8072
8133
  _this._moveDirection = null;
8073
8134
  };
8074
8135
  _this._onSideChanged = function (e) {
8075
- // this.visiblePanels.length 2보다 크다면 가로 방향 Flicking이 조작 중이라는 것을 의미합니다.
8076
- // 경우 가로 방향 Flicking의 이동이 완전히 끝난 _onHorizontalMoveEnd 에서 syncToCategory할 것이므로 여기서는 하지 않습니다.
8136
+ // If this.visiblePanels.length >= 2, it means that horizontal flicking is being dragged.
8137
+ // In this case, syncToCategory in _onHorizontalMoveEnd will fire after moving finishes, so we don't fire it here.
8077
8138
  if (_this.visiblePanels.length < 2 && _this._sideFlicking[_this.index] === e.currentTarget) {
8078
8139
  _this._syncToCategory(e.index, _this.index);
8079
8140
  }
8080
8141
  };
8142
+ var _a = options.sideOptions,
8143
+ sideOptions = _a === void 0 ? {} : _a,
8144
+ _b = options.preserveIndex,
8145
+ preserveIndex = _b === void 0 ? true : _b,
8146
+ _c = options.disableSlideOnHold,
8147
+ disableSlideOnHold = _c === void 0 ? true : _c,
8148
+ _d = options.disableIndexSync,
8149
+ disableIndexSync = _d === void 0 ? false : _d;
8081
8150
  // Internal states
8082
8151
  _this._moveDirection = null;
8083
8152
  _this._nextIndex = 0;
8153
+ _this._originalDragThreshold = _this.dragThreshold;
8084
8154
  // Bind options
8085
- _this._sideOptions = options.sideOptions;
8086
- _this._preserveIndex = options.preserveIndex;
8087
- _this._disableSlideOnHold = options.disableSlideOnHold;
8088
- _this._disableIndexSync = options.disableIndexSync;
8155
+ _this._sideOptions = sideOptions;
8156
+ _this._preserveIndex = preserveIndex;
8157
+ _this._disableSlideOnHold = disableSlideOnHold;
8158
+ _this._disableIndexSync = disableIndexSync;
8089
8159
  return _this;
8090
- // Create core components
8091
8160
  }
8092
8161
  var __proto = CrossFlicking.prototype;
8093
8162
  Object.defineProperty(__proto, "sideFlicking", {
@@ -8098,6 +8167,15 @@ version: 4.12.0-beta.8
8098
8167
  enumerable: false,
8099
8168
  configurable: true
8100
8169
  });
8170
+ Object.defineProperty(__proto, "sideIndex", {
8171
+ get: function () {
8172
+ return this._sideFlicking.map(function (i) {
8173
+ return i.index;
8174
+ });
8175
+ },
8176
+ enumerable: false,
8177
+ configurable: true
8178
+ });
8101
8179
  Object.defineProperty(__proto, "sideState", {
8102
8180
  get: function () {
8103
8181
  return this._sideState;
@@ -8156,7 +8234,9 @@ version: 4.12.0-beta.8
8156
8234
  });
8157
8235
  };
8158
8236
  __proto.destroy = function () {
8159
- // TODO 모든 child flicking destroy
8237
+ this._sideFlicking.forEach(function (flicking) {
8238
+ flicking.destroy();
8239
+ });
8160
8240
  _super.prototype.destroy.call(this);
8161
8241
  };
8162
8242
  __proto._addComponentEvents = function () {
@@ -8164,80 +8244,83 @@ version: 4.12.0-beta.8
8164
8244
  this.on(EVENTS.HOLD_START, this._onHorizontalHoldStart);
8165
8245
  this.on(EVENTS.MOVE, this._onHorizontalMove);
8166
8246
  this.on(EVENTS.MOVE_END, this._onHorizontalMoveEnd);
8167
- this._sideFlicking.forEach(function (flicking) {
8247
+ [EVENTS.CHANGED, EVENTS.WILL_CHANGE].forEach(function (event) {
8248
+ _this.on(event, _this._addSideIndex);
8249
+ });
8250
+ this._sideFlicking.forEach(function (flicking, mainIndex) {
8168
8251
  flicking.on(EVENTS.HOLD_START, _this._onSideHoldStart);
8169
8252
  flicking.on(EVENTS.MOVE, _this._onSideMove);
8170
8253
  flicking.on(EVENTS.MOVE_END, _this._onSideMoveEnd);
8171
8254
  flicking.on(EVENTS.CHANGED, _this._onSideChanged);
8255
+ Object.keys(SIDE_EVENTS).forEach(function (name) {
8256
+ flicking.on(EVENTS[name], function (event) {
8257
+ _this.trigger(new Component.ComponentEvent(SIDE_EVENTS[name], __assign({
8258
+ mainIndex: mainIndex
8259
+ }, event)));
8260
+ });
8261
+ });
8172
8262
  });
8173
8263
  };
8174
- __proto._getGroupFromAttribute = function (panels) {
8175
- var groupKeys = [];
8176
- var groupPanels = {};
8177
- panels.forEach(function (panel) {
8178
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8179
- if (groupKey && !includes(groupKeys, groupKey)) {
8180
- groupKeys.push(groupKey);
8181
- groupPanels[groupKey] = [panel];
8182
- } else if (groupKey) {
8183
- groupPanels[groupKey].push(panel);
8184
- }
8185
- });
8186
- return groupPanels;
8187
- };
8188
8264
  __proto._createSideState = function () {
8189
- var _this = this;
8190
8265
  var viewportEl = this.element;
8191
8266
  var cameraEl = this.camera.element;
8192
8267
  var panels = toArray(cameraEl.children);
8193
- var sideState = [];
8194
- var sidePanels = "";
8195
- // check data attribute exists
8196
- var sideCamera = document.createElement("div");
8197
- sideCamera.classList.add(CLASS.CAMERA);
8198
8268
  var isCrossStructure = getDataAttributes(viewportEl, "data-cross-").structure;
8269
+ var sideState = [];
8199
8270
  if (!isCrossStructure) {
8200
- viewportEl.setAttribute("data-cross-structure", "true");
8201
8271
  var groupPanels = this._getGroupFromAttribute(panels);
8202
8272
  var groupKeys = Object.keys(groupPanels);
8203
8273
  if (groupKeys.length) {
8204
8274
  sideState = this._getSideStateFromGroup(groupPanels);
8205
8275
  this.remove(0, this.panelCount - groupKeys.length);
8206
- sideState.forEach(function (state, i) {
8207
- var panel = _this.camera.children[i];
8208
- sidePanels += state.element.innerHTML;
8209
- Array.from(panel.attributes).forEach(function (attribute) {
8210
- return panel.removeAttribute(attribute.name);
8211
- });
8212
- });
8213
8276
  } else {
8214
- sideState = panels.reduce(function (state, panel, i) {
8215
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
8216
- sidePanels += panel.innerHTML;
8217
- return __spread(state, [{
8218
- key: i.toString(),
8219
- start: start,
8220
- end: start + panel.children.length - 1,
8221
- element: panel
8222
- }]);
8223
- }, []);
8277
+ sideState = this._getSideStateFromPanels(panels);
8224
8278
  }
8225
- sideCamera.innerHTML = sidePanels;
8226
- sideState.forEach(function (_, i) {
8227
- var panel = _this.camera.children[i];
8228
- [CLASS.VIEWPORT, CLASS.VERTICAL].forEach(function (className) {
8229
- if (!panel.classList.contains(className)) {
8230
- panel.classList.add(className);
8231
- }
8232
- });
8233
- panel.innerHTML = sideCamera.outerHTML;
8234
- });
8279
+ this._createCrossStructure(sideState);
8235
8280
  } else {
8236
- sideState = this._getSideStateFromPanels(panels);
8281
+ sideState = this._getSideStateFromCrossStructure(panels);
8237
8282
  }
8238
8283
  void this.resize();
8239
8284
  return sideState;
8240
8285
  };
8286
+ __proto._createCrossStructure = function (sideState) {
8287
+ var _this = this;
8288
+ var sideCamera = document.createElement("div");
8289
+ var sidePanels = "";
8290
+ sideCamera.classList.add(CLASS.CAMERA);
8291
+ sideState.forEach(function (state, i) {
8292
+ var panel = _this.camera.children[i];
8293
+ sidePanels += state.element.innerHTML;
8294
+ Array.from(panel.attributes).forEach(function (attribute) {
8295
+ return panel.removeAttribute(attribute.name);
8296
+ });
8297
+ });
8298
+ sideCamera.innerHTML = sidePanels;
8299
+ sideState.forEach(function (_, i) {
8300
+ var panel = _this.camera.children[i];
8301
+ [CLASS.VIEWPORT, CLASS.VERTICAL].forEach(function (className) {
8302
+ if (!panel.classList.contains(className)) {
8303
+ panel.classList.add(className);
8304
+ }
8305
+ });
8306
+ panel.innerHTML = sideCamera.outerHTML;
8307
+ });
8308
+ this.element.setAttribute("data-cross-structure", "true");
8309
+ };
8310
+ __proto._getGroupFromAttribute = function (panels) {
8311
+ var groupKeys = [];
8312
+ var groupPanels = {};
8313
+ panels.forEach(function (panel) {
8314
+ var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8315
+ if (groupKey && !includes(groupKeys, groupKey)) {
8316
+ groupKeys.push(groupKey);
8317
+ groupPanels[groupKey] = [panel];
8318
+ } else if (groupKey) {
8319
+ groupPanels[groupKey].push(panel);
8320
+ }
8321
+ });
8322
+ return groupPanels;
8323
+ };
8241
8324
  __proto._getSideStateFromGroup = function (groupPanels) {
8242
8325
  return Object.keys(groupPanels).reduce(function (state, key) {
8243
8326
  var start = state.length ? +state[state.length - 1].end + 1 : 0;
@@ -8254,6 +8337,17 @@ version: 4.12.0-beta.8
8254
8337
  }, []);
8255
8338
  };
8256
8339
  __proto._getSideStateFromPanels = function (panels) {
8340
+ return panels.reduce(function (state, panel, i) {
8341
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
8342
+ return __spread(state, [{
8343
+ key: i.toString(),
8344
+ start: start,
8345
+ end: start + panel.children.length - 1,
8346
+ element: panel
8347
+ }]);
8348
+ }, []);
8349
+ };
8350
+ __proto._getSideStateFromCrossStructure = function (panels) {
8257
8351
  var groupPanels = this._getGroupFromAttribute(panels);
8258
8352
  return this._getSideStateFromGroup(groupPanels);
8259
8353
  };
@@ -8263,30 +8357,16 @@ version: 4.12.0-beta.8
8263
8357
  return new Flicking(_this.camera.children[i], __assign(__assign({}, _this.sideOptions), {
8264
8358
  horizontal: false,
8265
8359
  panelsPerView: 1,
8266
- defaultIndex: state.start,
8267
- moveType: "strict"
8360
+ defaultIndex: state.start
8268
8361
  }));
8269
8362
  });
8270
8363
  };
8271
- __proto._syncToCategory = function (index, outerIndex) {
8272
- var _this = this;
8273
- this.stopAnimation();
8274
- this._sideFlicking.forEach(function (child, i) {
8275
- var _a = _this._sideState[i],
8276
- start = _a.start,
8277
- end = _a.end;
8278
- if (start <= index && end >= index && outerIndex !== i) {
8279
- child.stopAnimation();
8280
- void child.moveTo(index, 0);
8281
- void _this.moveTo(i, 0);
8282
- }
8283
- });
8284
- };
8285
8364
  return CrossFlicking;
8286
8365
  }(Flicking);
8287
8366
 
8288
8367
  var CrossFlicking$1 = {
8289
8368
  __proto__: null,
8369
+ SIDE_EVENTS: SIDE_EVENTS,
8290
8370
  CrossFlicking: CrossFlicking
8291
8371
  };
8292
8372