@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
@@ -1,47 +1,47 @@
1
- import Flicking, { FlickingOptions } from "./Flicking";
2
- import { ALIGN, DIRECTION } from "./const/external";
3
- import { LiteralUnion, Merged, ValueOf } from "./type/internal";
4
- import { ElementLike } from "./type/external";
5
- export declare const merge: <From extends object, To extends object>(target: From, ...sources: To[]) => Merged<From, To>;
6
- export declare const getElement: (el: HTMLElement | string | null, parent?: HTMLElement) => HTMLElement;
7
- export declare const checkExistence: (value: any, nameOnErrMsg: string) => void;
8
- export declare const clamp: (x: number, min: number, max: number) => number;
9
- export declare const getFlickingAttached: (val: Flicking | null) => Flicking;
10
- export declare const toArray: <T>(iterable: ArrayLike<T>) => T[];
11
- export declare const parseAlign: (align: LiteralUnion<ValueOf<typeof ALIGN>> | number, size: number) => number;
12
- export declare const parseBounce: (bounce: FlickingOptions["bounce"], size: number) => number[];
13
- export declare const parseArithmeticSize: (cssValue: number | string, base: number) => number | null;
14
- export declare const parseArithmeticExpression: (cssValue: number | string) => {
15
- percentage: number;
16
- absolute: number;
17
- } | null;
18
- export declare const parseCSSSizeValue: (val: string | number) => string;
19
- export declare const parsePanelAlign: (align: FlickingOptions["align"]) => string | number;
20
- export declare const getDirection: (start: number, end: number) => ValueOf<typeof DIRECTION>;
21
- export declare const parseElement: (element: ElementLike | ElementLike[]) => HTMLElement[];
22
- export declare const getMinusCompensatedIndex: (idx: number, max: number) => number;
23
- export declare const includes: <T>(array: T[], target: any) => target is T;
24
- export declare const isString: (val: any) => val is string;
25
- export declare const circulatePosition: (pos: number, min: number, max: number) => number;
26
- export declare const find: <T>(array: T[], checker: (val: T) => boolean) => T;
27
- export declare const findRight: <T>(array: T[], checker: (val: T) => boolean) => T;
28
- export declare const findIndex: <T>(array: T[], checker: (val: T) => boolean) => number;
29
- export declare const getProgress: (pos: number, prev: number, next: number) => number;
30
- export declare const getStyle: (el: HTMLElement) => CSSStyleDeclaration;
31
- export declare const setSize: (el: HTMLElement, { width, height }: Partial<{
32
- width: number | string;
33
- height: number | string;
34
- }>) => void;
35
- export declare const isBetween: (val: number, min: number, max: number) => boolean;
36
- export declare const circulateIndex: (index: number, max: number) => number;
37
- export declare const range: (end: number) => number[];
38
- export declare const getElementSize: ({ el, horizontal, useFractionalSize, useOffset, style }: {
39
- el: HTMLElement;
40
- horizontal: boolean;
41
- useFractionalSize: boolean;
42
- useOffset: boolean;
43
- style: CSSStyleDeclaration;
44
- }) => number;
45
- export declare const setPrototypeOf: (o: any, proto: object) => any;
46
- export declare const camelize: (str: string) => string;
47
- export declare const getDataAttributes: (element: HTMLElement, attributePrefix: string) => Record<string, string>;
1
+ import Flicking, { FlickingOptions } from "./Flicking";
2
+ import { ALIGN, DIRECTION } from "./const/external";
3
+ import { LiteralUnion, Merged, ValueOf } from "./type/internal";
4
+ import { ElementLike } from "./type/external";
5
+ export declare const merge: <From extends object, To extends object>(target: From, ...sources: To[]) => Merged<From, To>;
6
+ export declare const getElement: (el: HTMLElement | string | null, parent?: HTMLElement) => HTMLElement;
7
+ export declare const checkExistence: (value: any, nameOnErrMsg: string) => void;
8
+ export declare const clamp: (x: number, min: number, max: number) => number;
9
+ export declare const getFlickingAttached: (val: Flicking | null) => Flicking;
10
+ export declare const toArray: <T>(iterable: ArrayLike<T>) => T[];
11
+ export declare const parseAlign: (align: LiteralUnion<ValueOf<typeof ALIGN>> | number, size: number) => number;
12
+ export declare const parseBounce: (bounce: FlickingOptions["bounce"], size: number) => number[];
13
+ export declare const parseArithmeticSize: (cssValue: number | string, base: number) => number | null;
14
+ export declare const parseArithmeticExpression: (cssValue: number | string) => {
15
+ percentage: number;
16
+ absolute: number;
17
+ } | null;
18
+ export declare const parseCSSSizeValue: (val: string | number) => string;
19
+ export declare const parsePanelAlign: (align: FlickingOptions["align"]) => string | number;
20
+ export declare const getDirection: (start: number, end: number) => ValueOf<typeof DIRECTION>;
21
+ export declare const parseElement: (element: ElementLike | ElementLike[]) => HTMLElement[];
22
+ export declare const getMinusCompensatedIndex: (idx: number, max: number) => number;
23
+ export declare const includes: <T>(array: T[], target: any) => target is T;
24
+ export declare const isString: (val: any) => val is string;
25
+ export declare const circulatePosition: (pos: number, min: number, max: number) => number;
26
+ export declare const find: <T>(array: T[], checker: (val: T) => boolean) => T;
27
+ export declare const findRight: <T>(array: T[], checker: (val: T) => boolean) => T;
28
+ export declare const findIndex: <T>(array: T[], checker: (val: T) => boolean) => number;
29
+ export declare const getProgress: (pos: number, prev: number, next: number) => number;
30
+ export declare const getStyle: (el: HTMLElement) => CSSStyleDeclaration;
31
+ export declare const setSize: (el: HTMLElement, { width, height }: Partial<{
32
+ width: number | string;
33
+ height: number | string;
34
+ }>) => void;
35
+ export declare const isBetween: (val: number, min: number, max: number) => boolean;
36
+ export declare const circulateIndex: (index: number, max: number) => number;
37
+ export declare const range: (end: number) => number[];
38
+ export declare const getElementSize: ({ el, horizontal, useFractionalSize, useOffset, style }: {
39
+ el: HTMLElement;
40
+ horizontal: boolean;
41
+ useFractionalSize: boolean;
42
+ useOffset: boolean;
43
+ style: CSSStyleDeclaration;
44
+ }) => number;
45
+ export declare const setPrototypeOf: (o: any, proto: object) => any;
46
+ export declare const camelize: (str: string) => string;
47
+ export declare const getDataAttributes: (element: HTMLElement, attributePrefix: string) => Record<string, string>;
@@ -0,0 +1,37 @@
1
+ .flicking-viewport {
2
+ position: relative;
3
+ overflow: hidden;
4
+ }
5
+ .flicking-viewport:not(.vertical) {
6
+ width: 100%;
7
+ height: 100%;
8
+ }
9
+ .flicking-viewport.vertical, .flicking-viewport.vertical > .flicking-camera {
10
+ display: inline-block;
11
+ }
12
+ .flicking-viewport.vertical.middle > .flicking-camera > * {
13
+ vertical-align: middle;
14
+ }
15
+ .flicking-viewport.vertical.bottom > .flicking-camera > * {
16
+ vertical-align: bottom;
17
+ }
18
+ .flicking-viewport.vertical > .flicking-camera > * {
19
+ display: block;
20
+ }
21
+ .flicking-viewport.flicking-hidden > .flicking-camera > * {
22
+ visibility: hidden;
23
+ }
24
+
25
+ .flicking-camera {
26
+ width: 100%;
27
+ height: 100%;
28
+ position: relative;
29
+ z-index: 1;
30
+ white-space: nowrap;
31
+ will-change: transform;
32
+ }
33
+ .flicking-camera > * {
34
+ display: inline-block;
35
+ white-space: normal;
36
+ vertical-align: top;
37
+ }
@@ -0,0 +1 @@
1
+ .flicking-viewport{position:relative;overflow:hidden}.flicking-viewport:not(.vertical){width:100%;height:100%}.flicking-viewport.vertical,.flicking-viewport.vertical>.flicking-camera{display:inline-block}.flicking-viewport.vertical.middle>.flicking-camera>*{vertical-align:middle}.flicking-viewport.vertical.bottom>.flicking-camera>*{vertical-align:bottom}.flicking-viewport.vertical>.flicking-camera>*{display:block}.flicking-viewport.flicking-hidden>.flicking-camera>*{visibility:hidden}.flicking-camera{width:100%;height:100%;position:relative;z-index:1;white-space:nowrap;will-change:transform}.flicking-camera>*{display:inline-block;white-space:normal;vertical-align:top}
@@ -0,0 +1 @@
1
+ .flicking-viewport{position:relative;overflow:hidden}.flicking-viewport:not(.vertical){width:100%;height:100%}.flicking-viewport.vertical,.flicking-viewport.vertical>.flicking-camera{display:inline-block}.flicking-viewport.vertical.middle>.flicking-camera>*{vertical-align:middle}.flicking-viewport.vertical.bottom>.flicking-camera>*{vertical-align:bottom}.flicking-viewport.vertical>.flicking-camera>*{display:block}.flicking-viewport.flicking-hidden>.flicking-camera>*{visibility:hidden}.flicking-camera{width:100%;height:100%;position:relative;z-index:1;white-space:nowrap;will-change:transform}.flicking-camera>*{display:inline-block;white-space:normal;vertical-align:top}
@@ -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
  'use strict';
10
10
 
@@ -679,6 +679,9 @@ var getStyle = function (el) {
679
679
  var setSize = function (el, _a) {
680
680
  var width = _a.width,
681
681
  height = _a.height;
682
+ if (!el) {
683
+ return;
684
+ }
682
685
  if (width != null) {
683
686
  if (isString(width)) {
684
687
  el.style.width = width;
@@ -1592,6 +1595,9 @@ var HoldingState = /*#__PURE__*/function (_super) {
1592
1595
  axesEvent = ctx.axesEvent,
1593
1596
  transitTo = ctx.transitTo;
1594
1597
  var inputEvent = axesEvent.inputEvent;
1598
+ if (!inputEvent) {
1599
+ return;
1600
+ }
1595
1601
  var offset = flicking.horizontal ? inputEvent.offsetX : inputEvent.offsetY;
1596
1602
  var moveStartEvent = new Component.ComponentEvent(EVENTS.MOVE_START, {
1597
1603
  isTrusted: axesEvent.isTrusted,
@@ -3746,6 +3752,7 @@ var Camera = /*#__PURE__*/function () {
3746
3752
  var _this = this;
3747
3753
  var _b = (_a === void 0 ? {} : _a).align,
3748
3754
  align = _b === void 0 ? ALIGN.CENTER : _b;
3755
+ this._lookedOffset = 0;
3749
3756
  this._checkTranslateSupport = function () {
3750
3757
  var e_1, _a;
3751
3758
  var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
@@ -4105,6 +4112,8 @@ var Camera = /*#__PURE__*/function () {
4105
4112
  */
4106
4113
  __proto.lookAt = function (pos) {
4107
4114
  var _this = this;
4115
+ var prevOffset = this._offset;
4116
+ var isChangedOffset = this._lookedOffset !== prevOffset;
4108
4117
  var flicking = getFlickingAttached(this._flicking);
4109
4118
  var prevPos = this._position;
4110
4119
  this._position = pos;
@@ -4115,7 +4124,12 @@ var Camera = /*#__PURE__*/function () {
4115
4124
  if (toggled) {
4116
4125
  void flicking.renderer.render().then(function () {
4117
4126
  _this.updateOffset();
4127
+ _this._lookedOffset = _this._offset;
4118
4128
  });
4129
+ } else if (isChangedOffset) {
4130
+ // sync offset for renderOnlyVisible on resize
4131
+ this.updateOffset();
4132
+ this._lookedOffset = this._offset;
4119
4133
  } else {
4120
4134
  this.applyTransform();
4121
4135
  }
@@ -4290,8 +4304,8 @@ var Camera = /*#__PURE__*/function () {
4290
4304
  return this;
4291
4305
  };
4292
4306
  /**
4293
- * Update Viewport's height to active panel's height
4294
- * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4307
+ * Update Viewport's height to visible panel's max height
4308
+ * @ko 현재 활성화된 패널과 보이는 패널의 최대 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4295
4309
  * @throws {FlickingError}
4296
4310
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4297
4311
  * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
@@ -4301,9 +4315,17 @@ var Camera = /*#__PURE__*/function () {
4301
4315
  __proto.updateAdaptiveHeight = function () {
4302
4316
  var flicking = getFlickingAttached(this._flicking);
4303
4317
  var activePanel = flicking.control.activePanel;
4304
- if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
4318
+ var visiblePanels = flicking.visiblePanels;
4319
+ var selectedPanels = __spread(visiblePanels);
4320
+ if (activePanel) {
4321
+ selectedPanels.push(activePanel);
4322
+ }
4323
+ if (!flicking.horizontal || !flicking.adaptive || !selectedPanels.length) return;
4324
+ var maxHeight = Math.max.apply(Math, __spread(selectedPanels.map(function (panel) {
4325
+ return panel.height;
4326
+ })));
4305
4327
  flicking.viewport.setSize({
4306
- height: activePanel.height
4328
+ height: maxHeight
4307
4329
  });
4308
4330
  };
4309
4331
  /**
@@ -4374,6 +4396,7 @@ var Camera = /*#__PURE__*/function () {
4374
4396
  };
4375
4397
  __proto._resetInternalValues = function () {
4376
4398
  this._position = 0;
4399
+ this._lookedOffset = 0;
4377
4400
  this._alignPos = 0;
4378
4401
  this._offset = 0;
4379
4402
  this._circularOffset = 0;
@@ -5434,6 +5457,9 @@ var Panel = /*#__PURE__*/function () {
5434
5457
  var flicking = this._flicking;
5435
5458
  var horizontal = flicking.horizontal,
5436
5459
  useFractionalSize = flicking.useFractionalSize;
5460
+ if (!el) {
5461
+ return this;
5462
+ }
5437
5463
  if (cached) {
5438
5464
  this._size = cached.size;
5439
5465
  this._margin = __assign({}, cached.margin);
@@ -7841,7 +7867,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7841
7867
  var defaultPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
7842
7868
  if (!defaultPanel) return;
7843
7869
  var nearestAnchor = camera.findNearestAnchor(defaultPanel.position);
7844
- var initialPanel = nearestAnchor && defaultPanel.index !== nearestAnchor.panel.index ? nearestAnchor.panel : defaultPanel;
7870
+ var initialPanel = nearestAnchor && defaultPanel.position !== nearestAnchor.panel.position && defaultPanel.index !== nearestAnchor.panel.index ? nearestAnchor.panel : defaultPanel;
7845
7871
  control.setActive(initialPanel, null, false);
7846
7872
  if (!nearestAnchor) {
7847
7873
  throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(initialPanel.position), CODE.POSITION_NOT_REACHABLE);
@@ -7895,103 +7921,146 @@ var Flicking = /*#__PURE__*/function (_super) {
7895
7921
  * Flicking.VERSION; // ex) 4.0.0
7896
7922
  * ```
7897
7923
  */
7898
- Flicking.VERSION = "4.12.0-beta.8";
7924
+ Flicking.VERSION = "4.12.0";
7899
7925
  return Flicking;
7900
7926
  }(Component);
7901
7927
 
7902
- /*
7903
- * Copyright (c) 2015 NAVER Corp.
7904
- * egjs projects are licensed under the MIT license
7905
- */
7928
+ var SIDE_EVENTS = {
7929
+ HOLD_START: "sideHoldStart",
7930
+ HOLD_END: "sideHoldEnd",
7931
+ MOVE_START: "sideMoveStart",
7932
+ MOVE: "sideMove",
7933
+ MOVE_END: "sideMoveEnd",
7934
+ WILL_CHANGE: "sideWillChange",
7935
+ CHANGED: "sideChanged",
7936
+ WILL_RESTORE: "sideWillRestore",
7937
+ RESTORED: "sideRestored"
7938
+ };
7906
7939
  var CrossFlicking = /*#__PURE__*/function (_super) {
7907
7940
  __extends(CrossFlicking, _super);
7908
7941
  function CrossFlicking(root, options) {
7909
- if (options === void 0) {
7910
- options = {
7911
- sideOptions: {},
7912
- preserveIndex: false,
7913
- disableSlideOnHold: false,
7914
- disableIndexSync: false
7915
- };
7916
- }
7917
7942
  var _this = _super.call(this, root, options) || this;
7943
+ _this._syncToCategory = function (index, outerIndex) {
7944
+ if (_this._disableIndexSync) {
7945
+ return;
7946
+ }
7947
+ _this.stopAnimation();
7948
+ _this._sideFlicking.forEach(function (child, i) {
7949
+ var _a = _this._sideState[i],
7950
+ start = _a.start,
7951
+ end = _a.end;
7952
+ if (start <= index && end >= index && outerIndex !== i) {
7953
+ child.stopAnimation();
7954
+ void child.moveTo(index, 0);
7955
+ void _this.moveTo(i, 0);
7956
+ }
7957
+ });
7958
+ };
7959
+ _this._setDraggable = function (direction, draggable) {
7960
+ if (!_this._disableSlideOnHold) {
7961
+ return;
7962
+ }
7963
+ var dragThreshold = _this._originalDragThreshold;
7964
+ var threshold = draggable ? dragThreshold && dragThreshold >= 10 ? dragThreshold : 10 : Infinity;
7965
+ if (direction === MOVE_DIRECTION.HORIZONTAL === _this.horizontal) {
7966
+ _this.dragThreshold = threshold;
7967
+ } else if (direction === MOVE_DIRECTION.VERTICAL === _this.horizontal) {
7968
+ _this._sideFlicking.forEach(function (child) {
7969
+ child.dragThreshold = threshold;
7970
+ });
7971
+ }
7972
+ };
7973
+ _this._setPreviousSideIndex = function () {
7974
+ _this._sideFlicking.forEach(function (child, i) {
7975
+ var _a = _this._sideState[i],
7976
+ start = _a.start,
7977
+ end = _a.end;
7978
+ if (_this._preserveIndex) {
7979
+ if (_this._nextIndex !== i) {
7980
+ if (child.index < start) {
7981
+ child.stopAnimation();
7982
+ void child.moveTo(start, 0);
7983
+ } else if (child.index > end) {
7984
+ child.stopAnimation();
7985
+ void child.moveTo(end, 0);
7986
+ }
7987
+ }
7988
+ } else {
7989
+ if (_this._nextIndex !== i) {
7990
+ void child.moveTo(start, 0);
7991
+ }
7992
+ }
7993
+ });
7994
+ };
7995
+ _this._addSideIndex = function (e) {
7996
+ e.sideIndex = _this._sideFlicking[e.index].index;
7997
+ };
7918
7998
  _this._onHorizontalHoldStart = function () {
7919
- _this.dragThreshold = 10;
7999
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
7920
8000
  _this._moveDirection = null;
7921
8001
  };
7922
8002
  _this._onHorizontalMove = function (e) {
7923
8003
  if (e.isTrusted && !_this._moveDirection) {
7924
- _this._sideFlicking.forEach(function (child) {
7925
- child.dragThreshold = Infinity;
7926
- });
8004
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, false);
7927
8005
  _this._moveDirection = MOVE_DIRECTION.HORIZONTAL;
7928
8006
  }
7929
8007
  };
7930
8008
  _this._onHorizontalMoveEnd = function (e) {
7931
8009
  var visiblePanels = _this.visiblePanels;
7932
- _this._sideFlicking.forEach(function (child) {
7933
- child.dragThreshold = 10;
7934
- });
7935
- _this._moveDirection = null;
7936
8010
  if (visiblePanels.length > 1) {
7937
8011
  _this._nextIndex = e.direction === "NEXT" ? visiblePanels[1].index : visiblePanels[0].index;
7938
8012
  } else {
7939
8013
  _this._nextIndex = visiblePanels[0].index;
7940
8014
  }
8015
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
8016
+ _this._moveDirection = null;
7941
8017
  // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 requestAnimationFrame 처리
7942
8018
  requestAnimationFrame(function () {
7943
- _this._sideFlicking.forEach(function (child, i) {
7944
- if (_this._nextIndex !== i) {
7945
- var _a = _this._sideState[i],
7946
- start = _a.start,
7947
- end = _a.end;
7948
- if (child.index < start) {
7949
- child.stopAnimation();
7950
- void child.moveTo(start, 0);
7951
- } else if (child.index > end) {
7952
- child.stopAnimation();
7953
- void child.moveTo(end, 0);
7954
- }
7955
- }
7956
- });
8019
+ return _this._setPreviousSideIndex();
7957
8020
  });
7958
8021
  if (e.isTrusted) {
7959
8022
  _this._syncToCategory(_this._sideFlicking[_this._nextIndex].index, _this._nextIndex);
7960
8023
  }
7961
8024
  };
7962
8025
  _this._onSideHoldStart = function () {
7963
- _this._sideFlicking.forEach(function (child) {
7964
- child.dragThreshold = 10;
7965
- });
8026
+ _this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
7966
8027
  _this._moveDirection = null;
7967
8028
  };
7968
8029
  _this._onSideMove = function (e) {
7969
8030
  if (e.isTrusted && !_this._moveDirection) {
7970
- _this.dragThreshold = Infinity;
8031
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, false);
7971
8032
  _this._moveDirection = MOVE_DIRECTION.VERTICAL;
7972
8033
  }
7973
8034
  };
7974
8035
  _this._onSideMoveEnd = function () {
7975
- _this.dragThreshold = 10;
8036
+ _this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
7976
8037
  _this._moveDirection = null;
7977
8038
  };
7978
8039
  _this._onSideChanged = function (e) {
7979
- // this.visiblePanels.length 2보다 크다면 가로 방향 Flicking이 조작 중이라는 것을 의미합니다.
7980
- // 경우 가로 방향 Flicking의 이동이 완전히 끝난 _onHorizontalMoveEnd 에서 syncToCategory할 것이므로 여기서는 하지 않습니다.
8040
+ // If this.visiblePanels.length >= 2, it means that horizontal flicking is being dragged.
8041
+ // In this case, syncToCategory in _onHorizontalMoveEnd will fire after moving finishes, so we don't fire it here.
7981
8042
  if (_this.visiblePanels.length < 2 && _this._sideFlicking[_this.index] === e.currentTarget) {
7982
8043
  _this._syncToCategory(e.index, _this.index);
7983
8044
  }
7984
8045
  };
8046
+ var _a = options.sideOptions,
8047
+ sideOptions = _a === void 0 ? {} : _a,
8048
+ _b = options.preserveIndex,
8049
+ preserveIndex = _b === void 0 ? true : _b,
8050
+ _c = options.disableSlideOnHold,
8051
+ disableSlideOnHold = _c === void 0 ? true : _c,
8052
+ _d = options.disableIndexSync,
8053
+ disableIndexSync = _d === void 0 ? false : _d;
7985
8054
  // Internal states
7986
8055
  _this._moveDirection = null;
7987
8056
  _this._nextIndex = 0;
8057
+ _this._originalDragThreshold = _this.dragThreshold;
7988
8058
  // Bind options
7989
- _this._sideOptions = options.sideOptions;
7990
- _this._preserveIndex = options.preserveIndex;
7991
- _this._disableSlideOnHold = options.disableSlideOnHold;
7992
- _this._disableIndexSync = options.disableIndexSync;
8059
+ _this._sideOptions = sideOptions;
8060
+ _this._preserveIndex = preserveIndex;
8061
+ _this._disableSlideOnHold = disableSlideOnHold;
8062
+ _this._disableIndexSync = disableIndexSync;
7993
8063
  return _this;
7994
- // Create core components
7995
8064
  }
7996
8065
  var __proto = CrossFlicking.prototype;
7997
8066
  Object.defineProperty(__proto, "sideFlicking", {
@@ -8002,6 +8071,15 @@ var CrossFlicking = /*#__PURE__*/function (_super) {
8002
8071
  enumerable: false,
8003
8072
  configurable: true
8004
8073
  });
8074
+ Object.defineProperty(__proto, "sideIndex", {
8075
+ get: function () {
8076
+ return this._sideFlicking.map(function (i) {
8077
+ return i.index;
8078
+ });
8079
+ },
8080
+ enumerable: false,
8081
+ configurable: true
8082
+ });
8005
8083
  Object.defineProperty(__proto, "sideState", {
8006
8084
  get: function () {
8007
8085
  return this._sideState;
@@ -8060,7 +8138,9 @@ var CrossFlicking = /*#__PURE__*/function (_super) {
8060
8138
  });
8061
8139
  };
8062
8140
  __proto.destroy = function () {
8063
- // TODO 모든 child flicking destroy
8141
+ this._sideFlicking.forEach(function (flicking) {
8142
+ flicking.destroy();
8143
+ });
8064
8144
  _super.prototype.destroy.call(this);
8065
8145
  };
8066
8146
  __proto._addComponentEvents = function () {
@@ -8068,80 +8148,83 @@ var CrossFlicking = /*#__PURE__*/function (_super) {
8068
8148
  this.on(EVENTS.HOLD_START, this._onHorizontalHoldStart);
8069
8149
  this.on(EVENTS.MOVE, this._onHorizontalMove);
8070
8150
  this.on(EVENTS.MOVE_END, this._onHorizontalMoveEnd);
8071
- this._sideFlicking.forEach(function (flicking) {
8151
+ [EVENTS.CHANGED, EVENTS.WILL_CHANGE].forEach(function (event) {
8152
+ _this.on(event, _this._addSideIndex);
8153
+ });
8154
+ this._sideFlicking.forEach(function (flicking, mainIndex) {
8072
8155
  flicking.on(EVENTS.HOLD_START, _this._onSideHoldStart);
8073
8156
  flicking.on(EVENTS.MOVE, _this._onSideMove);
8074
8157
  flicking.on(EVENTS.MOVE_END, _this._onSideMoveEnd);
8075
8158
  flicking.on(EVENTS.CHANGED, _this._onSideChanged);
8159
+ Object.keys(SIDE_EVENTS).forEach(function (name) {
8160
+ flicking.on(EVENTS[name], function (event) {
8161
+ _this.trigger(new Component.ComponentEvent(SIDE_EVENTS[name], __assign({
8162
+ mainIndex: mainIndex
8163
+ }, event)));
8164
+ });
8165
+ });
8076
8166
  });
8077
8167
  };
8078
- __proto._getGroupFromAttribute = function (panels) {
8079
- var groupKeys = [];
8080
- var groupPanels = {};
8081
- panels.forEach(function (panel) {
8082
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8083
- if (groupKey && !includes(groupKeys, groupKey)) {
8084
- groupKeys.push(groupKey);
8085
- groupPanels[groupKey] = [panel];
8086
- } else if (groupKey) {
8087
- groupPanels[groupKey].push(panel);
8088
- }
8089
- });
8090
- return groupPanels;
8091
- };
8092
8168
  __proto._createSideState = function () {
8093
- var _this = this;
8094
8169
  var viewportEl = this.element;
8095
8170
  var cameraEl = this.camera.element;
8096
8171
  var panels = toArray(cameraEl.children);
8097
- var sideState = [];
8098
- var sidePanels = "";
8099
- // check data attribute exists
8100
- var sideCamera = document.createElement("div");
8101
- sideCamera.classList.add(CLASS.CAMERA);
8102
8172
  var isCrossStructure = getDataAttributes(viewportEl, "data-cross-").structure;
8173
+ var sideState = [];
8103
8174
  if (!isCrossStructure) {
8104
- viewportEl.setAttribute("data-cross-structure", "true");
8105
8175
  var groupPanels = this._getGroupFromAttribute(panels);
8106
8176
  var groupKeys = Object.keys(groupPanels);
8107
8177
  if (groupKeys.length) {
8108
8178
  sideState = this._getSideStateFromGroup(groupPanels);
8109
8179
  this.remove(0, this.panelCount - groupKeys.length);
8110
- sideState.forEach(function (state, i) {
8111
- var panel = _this.camera.children[i];
8112
- sidePanels += state.element.innerHTML;
8113
- Array.from(panel.attributes).forEach(function (attribute) {
8114
- return panel.removeAttribute(attribute.name);
8115
- });
8116
- });
8117
8180
  } else {
8118
- sideState = panels.reduce(function (state, panel, i) {
8119
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
8120
- sidePanels += panel.innerHTML;
8121
- return __spread(state, [{
8122
- key: i.toString(),
8123
- start: start,
8124
- end: start + panel.children.length - 1,
8125
- element: panel
8126
- }]);
8127
- }, []);
8181
+ sideState = this._getSideStateFromPanels(panels);
8128
8182
  }
8129
- sideCamera.innerHTML = sidePanels;
8130
- sideState.forEach(function (_, i) {
8131
- var panel = _this.camera.children[i];
8132
- [CLASS.VIEWPORT, CLASS.VERTICAL].forEach(function (className) {
8133
- if (!panel.classList.contains(className)) {
8134
- panel.classList.add(className);
8135
- }
8136
- });
8137
- panel.innerHTML = sideCamera.outerHTML;
8138
- });
8183
+ this._createCrossStructure(sideState);
8139
8184
  } else {
8140
- sideState = this._getSideStateFromPanels(panels);
8185
+ sideState = this._getSideStateFromCrossStructure(panels);
8141
8186
  }
8142
8187
  void this.resize();
8143
8188
  return sideState;
8144
8189
  };
8190
+ __proto._createCrossStructure = function (sideState) {
8191
+ var _this = this;
8192
+ var sideCamera = document.createElement("div");
8193
+ var sidePanels = "";
8194
+ sideCamera.classList.add(CLASS.CAMERA);
8195
+ sideState.forEach(function (state, i) {
8196
+ var panel = _this.camera.children[i];
8197
+ sidePanels += state.element.innerHTML;
8198
+ Array.from(panel.attributes).forEach(function (attribute) {
8199
+ return panel.removeAttribute(attribute.name);
8200
+ });
8201
+ });
8202
+ sideCamera.innerHTML = sidePanels;
8203
+ sideState.forEach(function (_, i) {
8204
+ var panel = _this.camera.children[i];
8205
+ [CLASS.VIEWPORT, CLASS.VERTICAL].forEach(function (className) {
8206
+ if (!panel.classList.contains(className)) {
8207
+ panel.classList.add(className);
8208
+ }
8209
+ });
8210
+ panel.innerHTML = sideCamera.outerHTML;
8211
+ });
8212
+ this.element.setAttribute("data-cross-structure", "true");
8213
+ };
8214
+ __proto._getGroupFromAttribute = function (panels) {
8215
+ var groupKeys = [];
8216
+ var groupPanels = {};
8217
+ panels.forEach(function (panel) {
8218
+ var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8219
+ if (groupKey && !includes(groupKeys, groupKey)) {
8220
+ groupKeys.push(groupKey);
8221
+ groupPanels[groupKey] = [panel];
8222
+ } else if (groupKey) {
8223
+ groupPanels[groupKey].push(panel);
8224
+ }
8225
+ });
8226
+ return groupPanels;
8227
+ };
8145
8228
  __proto._getSideStateFromGroup = function (groupPanels) {
8146
8229
  return Object.keys(groupPanels).reduce(function (state, key) {
8147
8230
  var start = state.length ? +state[state.length - 1].end + 1 : 0;
@@ -8158,6 +8241,17 @@ var CrossFlicking = /*#__PURE__*/function (_super) {
8158
8241
  }, []);
8159
8242
  };
8160
8243
  __proto._getSideStateFromPanels = function (panels) {
8244
+ return panels.reduce(function (state, panel, i) {
8245
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
8246
+ return __spread(state, [{
8247
+ key: i.toString(),
8248
+ start: start,
8249
+ end: start + panel.children.length - 1,
8250
+ element: panel
8251
+ }]);
8252
+ }, []);
8253
+ };
8254
+ __proto._getSideStateFromCrossStructure = function (panels) {
8161
8255
  var groupPanels = this._getGroupFromAttribute(panels);
8162
8256
  return this._getSideStateFromGroup(groupPanels);
8163
8257
  };
@@ -8167,25 +8261,10 @@ var CrossFlicking = /*#__PURE__*/function (_super) {
8167
8261
  return new Flicking(_this.camera.children[i], __assign(__assign({}, _this.sideOptions), {
8168
8262
  horizontal: false,
8169
8263
  panelsPerView: 1,
8170
- defaultIndex: state.start,
8171
- moveType: "strict"
8264
+ defaultIndex: state.start
8172
8265
  }));
8173
8266
  });
8174
8267
  };
8175
- __proto._syncToCategory = function (index, outerIndex) {
8176
- var _this = this;
8177
- this.stopAnimation();
8178
- this._sideFlicking.forEach(function (child, i) {
8179
- var _a = _this._sideState[i],
8180
- start = _a.start,
8181
- end = _a.end;
8182
- if (start <= index && end >= index && outerIndex !== i) {
8183
- child.stopAnimation();
8184
- void child.moveTo(index, 0);
8185
- void _this.moveTo(i, 0);
8186
- }
8187
- });
8188
- };
8189
8268
  return CrossFlicking;
8190
8269
  }(Flicking);
8191
8270
 
@@ -8406,6 +8485,7 @@ var parseAlign = function (alignVal) {
8406
8485
  var modules = {
8407
8486
  __proto__: null,
8408
8487
  'default': Flicking,
8488
+ SIDE_EVENTS: SIDE_EVENTS,
8409
8489
  CrossFlicking: CrossFlicking,
8410
8490
  VanillaElementProvider: VanillaElementProvider,
8411
8491
  VirtualElementProvider: VirtualElementProvider,
@@ -8519,6 +8599,7 @@ exports.NormalRenderingStrategy = NormalRenderingStrategy;
8519
8599
  exports.ORDER = ORDER;
8520
8600
  exports.Panel = Panel;
8521
8601
  exports.Renderer = Renderer;
8602
+ exports.SIDE_EVENTS = SIDE_EVENTS;
8522
8603
  exports.SnapControl = SnapControl;
8523
8604
  exports.State = State;
8524
8605
  exports.StateMachine = StateMachine;