@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egjs/flicking",
3
- "version": "4.12.0-beta.8",
3
+ "version": "4.12.0",
4
4
  "description": "Everyday 30 million people experience. It's reliable, flexible and extendable carousel.",
5
5
  "main": "dist/flicking.cjs.js",
6
6
  "module": "dist/flicking.esm.js",
@@ -12,13 +12,12 @@
12
12
  "types": "declaration/index.d.ts",
13
13
  "scripts": {
14
14
  "start": "concurrently \"rollup -w --config ./rollup.config.dev.js\" \"http-serve\"",
15
- "build": "run-s build:bundle build:declaration printsizes",
16
- "build-react": "run-s build:bundle build:declaration && pvu --build=react-flicking",
15
+ "build": "run-s build:bundle build:declaration build:css printsizes",
17
16
  "build:bundle": "rm -rf ./dist && rollup -c",
18
17
  "build:declaration": "rm -rf ./declaration && tsc -p tsconfig.declaration.json",
19
18
  "build:css": "run-s build:css-clear build:sass build:css-prefix build:css-min",
20
19
  "build:css-clear": "rm -rf ./dist/*.css",
21
- "build:sass": "node-sass sass/ -o dist/ -x --output-style expanded",
20
+ "build:sass": "sass sass/:dist/ --style=expanded --no-source-map && sass sass/flicking.sass dist/flicking.min.css --style=compressed --no-source-map && sass sass/flicking-inline.sass dist/flicking-inline.min.css --style=compressed --no-source-map",
22
21
  "build:css-prefix": "postcss dist/*.css --replace --use autoprefixer --no-map",
23
22
  "build:css-min": "postcss dist/*.css --ext .min.css --use postcss-clean -d dist/ --no-map",
24
23
  "declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json",
@@ -115,7 +114,6 @@
115
114
  "husky": "^1.3.1",
116
115
  "jsdoc-to-mdx": "^1.1.2",
117
116
  "karma-typescript-es6-transform": "^5.5.2",
118
- "node-sass": "^7.0.1",
119
117
  "npm-run-all": "^4.1.5",
120
118
  "postcss-clean": "^1.2.2",
121
119
  "postcss-cli": "^7.1.2",
@@ -130,6 +128,7 @@
130
128
  "rollup-plugin-terser": "^7.0.2",
131
129
  "rollup-plugin-typescript2": "^0.36.0",
132
130
  "rollup-plugin-visualizer": "^4.2.1",
131
+ "sass": "^1.79.3",
133
132
  "sync-exec": "^0.6.2",
134
133
  "ts-mock-imports": "^1.3.3",
135
134
  "tsconfig-paths-webpack-plugin": "^3.5.1",
@@ -140,7 +139,7 @@
140
139
  "typescript-transform-paths": "^2.2.3"
141
140
  },
142
141
  "dependencies": {
143
- "@egjs/axes": "^3.9.0",
142
+ "@egjs/axes": "^3.9.1",
144
143
  "@egjs/component": "^3.0.1",
145
144
  "@egjs/imready": "^1.3.1",
146
145
  "@egjs/list-differ": "^1.0.1"
@@ -2,9 +2,16 @@
2
2
  position: relative
3
3
  overflow: hidden
4
4
  &.vertical
5
+ display: -webkit-inline-box
6
+ display: -ms-inline-flexbox
5
7
  display: inline-flex
6
8
  >.flicking-camera
9
+ display: -webkit-inline-box
10
+ display: -ms-inline-flexbox
7
11
  display: inline-flex
12
+ -webkit-box-orient: vertical
13
+ -webkit-box-direction: normal
14
+ -ms-flex-direction: column
8
15
  flex-direction: column
9
16
  &.flicking-hidden
10
17
  >.flicking-camera
@@ -14,10 +21,16 @@
14
21
  .flicking-camera
15
22
  width: 100%
16
23
  height: 100%
24
+ display: -webkit-box
25
+ display: -ms-flexbox
17
26
  display: flex
18
27
  position: relative
28
+ -webkit-box-orient: horizontal
29
+ -webkit-box-direction: normal
30
+ -ms-flex-direction: row
19
31
  flex-direction: row
20
32
  z-index: 1
21
33
  will-change: transform
22
34
  >*
35
+ -ms-flex-negative: 0
23
36
  flex-shrink: 0
@@ -2,15 +2,49 @@
2
2
  * Copyright (c) 2015 NAVER Corp.
3
3
  * egjs projects are licensed under the MIT license
4
4
  */
5
-
6
- import Flicking, { FlickingOptions } from "./Flicking";
7
- import { ChangedEvent, MoveEndEvent, MoveEvent } from "./type/event";
5
+ import { ComponentEvent } from "@egjs/component";
6
+ import { EventKey } from "@egjs/component/declaration/types";
7
+
8
+ import Flicking, { FlickingEvents, FlickingOptions } from "./Flicking";
9
+ import {
10
+ ChangedEvent,
11
+ HoldEndEvent,
12
+ HoldStartEvent,
13
+ MoveEndEvent,
14
+ MoveEvent,
15
+ MoveStartEvent,
16
+ RestoredEvent,
17
+ WillChangeEvent,
18
+ WillRestoreEvent
19
+ } from "./type/event";
8
20
  import { LiteralUnion, ValueOf } from "./type/internal";
9
21
  import { CLASS, EVENTS, MOVE_DIRECTION } from "./const/external";
10
22
  import { getDataAttributes, includes, toArray } from "./utils";
11
23
 
12
- export interface CrossFlickingEvents {
13
- // FlickingEvent 들을 확장하자...
24
+ export const SIDE_EVENTS = {
25
+ HOLD_START: "sideHoldStart",
26
+ HOLD_END: "sideHoldEnd",
27
+ MOVE_START: "sideMoveStart",
28
+ MOVE: "sideMove",
29
+ MOVE_END: "sideMoveEnd",
30
+ WILL_CHANGE: "sideWillChange",
31
+ CHANGED: "sideChanged",
32
+ WILL_RESTORE: "sideWillRestore",
33
+ RESTORED: "sideRestored"
34
+ } as const;
35
+
36
+ export type CrossFlickingEvent<T> = { mainIndex: number } & T;
37
+
38
+ export interface CrossFlickingEvents extends FlickingEvents {
39
+ [SIDE_EVENTS.HOLD_START]: CrossFlickingEvent<HoldStartEvent>;
40
+ [SIDE_EVENTS.HOLD_END]: CrossFlickingEvent<HoldEndEvent>;
41
+ [SIDE_EVENTS.MOVE_START]: CrossFlickingEvent<MoveStartEvent>;
42
+ [SIDE_EVENTS.MOVE]: CrossFlickingEvent<MoveEvent>;
43
+ [SIDE_EVENTS.MOVE_END]: CrossFlickingEvent<MoveEndEvent>;
44
+ [SIDE_EVENTS.WILL_CHANGE]: CrossFlickingEvent<WillChangeEvent>;
45
+ [SIDE_EVENTS.CHANGED]: CrossFlickingEvent<ChangedEvent>;
46
+ [SIDE_EVENTS.WILL_RESTORE]: CrossFlickingEvent<WillRestoreEvent>;
47
+ [SIDE_EVENTS.RESTORED]: CrossFlickingEvent<RestoredEvent>;
14
48
  }
15
49
 
16
50
  export interface CrossFlickingOptions extends FlickingOptions {
@@ -27,6 +61,14 @@ export interface SideState {
27
61
  element: HTMLElement;
28
62
  }
29
63
 
64
+ export interface CrossFlickingChangedEvent extends ChangedEvent {
65
+ sideIndex?: number;
66
+ }
67
+
68
+ export interface CrossFlickingWillChangeEvent extends WillChangeEvent {
69
+ sideIndex?: number;
70
+ }
71
+
30
72
  export class CrossFlicking extends Flicking {
31
73
  // Core components
32
74
  private _sideFlicking: Flicking[];
@@ -40,6 +82,7 @@ export class CrossFlicking extends Flicking {
40
82
  // Internal State
41
83
  private _sideState: SideState[];
42
84
  private _moveDirection: LiteralUnion<ValueOf<typeof MOVE_DIRECTION>> | null;
85
+ private _originalDragThreshold: number;
43
86
  private _nextIndex: number;
44
87
 
45
88
  // Components
@@ -47,6 +90,10 @@ export class CrossFlicking extends Flicking {
47
90
  return this._sideFlicking;
48
91
  }
49
92
 
93
+ public get sideIndex() {
94
+ return this._sideFlicking.map(i => i.index);
95
+ }
96
+
50
97
  public get sideState() {
51
98
  return this._sideState;
52
99
  }
@@ -64,38 +111,41 @@ export class CrossFlicking extends Flicking {
64
111
  public set sideOptions(val: CrossFlickingOptions["sideOptions"]) {
65
112
  this._sideOptions = val;
66
113
  }
114
+
67
115
  public set preserveIndex(val: CrossFlickingOptions["preserveIndex"]) {
68
116
  this._preserveIndex = val;
69
117
  }
118
+
70
119
  public set disableSlideOnHold(val: CrossFlickingOptions["disableSlideOnHold"]) {
71
120
  this._disableSlideOnHold = val;
72
121
  }
122
+
73
123
  public set disableIndexSync(val: CrossFlickingOptions["disableIndexSync"]) {
74
124
  this._disableIndexSync = val;
75
125
  }
76
126
 
77
127
  public constructor(
78
128
  root: HTMLElement | string,
79
- options: Partial<CrossFlickingOptions> = {
80
- sideOptions: {},
81
- preserveIndex: false,
82
- disableSlideOnHold: false,
83
- disableIndexSync: false,
84
- }
129
+ options: Partial<CrossFlickingOptions>
85
130
  ) {
86
131
  super(root, options);
132
+ const {
133
+ sideOptions = {},
134
+ preserveIndex = true,
135
+ disableSlideOnHold = true,
136
+ disableIndexSync = false
137
+ } = options;
87
138
 
88
139
  // Internal states
89
140
  this._moveDirection = null;
90
141
  this._nextIndex = 0;
142
+ this._originalDragThreshold = this.dragThreshold;
91
143
 
92
144
  // Bind options
93
- this._sideOptions = options.sideOptions;
94
- this._preserveIndex = options.preserveIndex;
95
- this._disableSlideOnHold = options.disableSlideOnHold;
96
- this._disableIndexSync = options.disableIndexSync;
97
-
98
- // Create core components
145
+ this._sideOptions = sideOptions;
146
+ this._preserveIndex = preserveIndex;
147
+ this._disableSlideOnHold = disableSlideOnHold;
148
+ this._disableIndexSync = disableIndexSync;
99
149
  }
100
150
 
101
151
  public init(): Promise<void> {
@@ -107,7 +157,9 @@ export class CrossFlicking extends Flicking {
107
157
  }
108
158
 
109
159
  public destroy(): void {
110
- // TODO 모든 child flicking destroy
160
+ this._sideFlicking.forEach((flicking) => {
161
+ flicking.destroy();
162
+ });
111
163
  super.destroy();
112
164
  }
113
165
 
@@ -115,93 +167,53 @@ export class CrossFlicking extends Flicking {
115
167
  this.on(EVENTS.HOLD_START, this._onHorizontalHoldStart);
116
168
  this.on(EVENTS.MOVE, this._onHorizontalMove);
117
169
  this.on(EVENTS.MOVE_END, this._onHorizontalMoveEnd);
170
+ [EVENTS.CHANGED, EVENTS.WILL_CHANGE].forEach((event) => {
171
+ this.on(event, this._addSideIndex);
172
+ });
118
173
 
119
- this._sideFlicking.forEach((flicking) => {
174
+ this._sideFlicking.forEach((flicking, mainIndex) => {
120
175
  flicking.on(EVENTS.HOLD_START, this._onSideHoldStart);
121
176
  flicking.on(EVENTS.MOVE, this._onSideMove);
122
177
  flicking.on(EVENTS.MOVE_END, this._onSideMoveEnd);
123
178
  flicking.on(EVENTS.CHANGED, this._onSideChanged);
124
- });
125
- }
126
179
 
127
- private _getGroupFromAttribute(panels: HTMLElement[]): Record<string, HTMLElement[]> {
128
- const groupKeys: string[] = [];
129
- const groupPanels: Record<string, HTMLElement[]> = {};
130
-
131
- panels.forEach((panel) => {
132
- const groupKey = getDataAttributes(panel, "data-cross-").groupkey;
133
- if (groupKey && !includes(groupKeys, groupKey)) {
134
- groupKeys.push(groupKey);
135
- groupPanels[groupKey] = [panel];
136
- } else if (groupKey) {
137
- groupPanels[groupKey].push(panel);
138
- }
180
+ Object.keys(SIDE_EVENTS).forEach((name: EventKey<FlickingEvents>) => {
181
+ flicking.on(EVENTS[name], (event) => {
182
+ this.trigger(
183
+ new ComponentEvent(SIDE_EVENTS[name], {
184
+ mainIndex,
185
+ ...event
186
+ })
187
+ );
188
+ });
189
+ });
139
190
  });
140
-
141
- return groupPanels;
142
191
  }
143
192
 
144
193
  private _createSideState(): SideState[] {
145
194
  const viewportEl = this.element;
146
195
  const cameraEl = this.camera.element;
147
196
  const panels = toArray(cameraEl.children) as HTMLElement[];
148
- let sideState: SideState[] = [];
149
- let sidePanels: string = "";
150
-
151
- // check data attribute exists
152
- const sideCamera = document.createElement("div");
153
- sideCamera.classList.add(CLASS.CAMERA);
154
-
155
197
  const isCrossStructure = getDataAttributes(
156
198
  viewportEl,
157
199
  "data-cross-"
158
200
  ).structure;
201
+ let sideState: SideState[] = [];
159
202
 
160
203
  if (!isCrossStructure) {
161
- viewportEl.setAttribute("data-cross-structure", "true");
162
-
163
204
  const groupPanels = this._getGroupFromAttribute(panels);
164
205
  const groupKeys = Object.keys(groupPanels);
165
206
 
166
207
  if (groupKeys.length) {
167
208
  sideState = this._getSideStateFromGroup(groupPanels);
168
209
  this.remove(0, this.panelCount - groupKeys.length);
169
- sideState.forEach((state, i) => {
170
- const panel = this.camera.children[i];
171
- sidePanels += state.element.innerHTML;
172
- Array.from(panel.attributes).forEach(attribute => panel.removeAttribute(attribute.name));
173
- });
174
210
  } else {
175
- sideState = panels.reduce(
176
- (state: SideState[], panel: HTMLElement, i: number) => {
177
- const start = state.length ? +state[state.length - 1].end + 1 : 0;
178
- sidePanels += panel.innerHTML;
179
- return [
180
- ...state,
181
- {
182
- key: i.toString(),
183
- start,
184
- end: start + panel.children.length - 1,
185
- element: panel,
186
- },
187
- ];
188
- },
189
- []
190
- );
211
+ sideState = this._getSideStateFromPanels(panels);
191
212
  }
192
213
 
193
- sideCamera.innerHTML = sidePanels;
194
- sideState.forEach((_, i) => {
195
- const panel = this.camera.children[i];
196
- [CLASS.VIEWPORT, CLASS.VERTICAL].forEach((className) => {
197
- if (!panel.classList.contains(className)) {
198
- panel.classList.add(className);
199
- }
200
- });
201
- panel.innerHTML = sideCamera.outerHTML;
202
- });
214
+ this._createCrossStructure(sideState);
203
215
  } else {
204
- sideState = this._getSideStateFromPanels(panels);
216
+ sideState = this._getSideStateFromCrossStructure(panels);
205
217
  }
206
218
 
207
219
  void this.resize();
@@ -209,7 +221,56 @@ export class CrossFlicking extends Flicking {
209
221
  return sideState;
210
222
  }
211
223
 
212
- private _getSideStateFromGroup(groupPanels: Record<string, HTMLElement[]>): SideState[] {
224
+ private _createCrossStructure(sideState: SideState[]) {
225
+ const sideCamera = document.createElement("div");
226
+ let sidePanels: string = "";
227
+
228
+ sideCamera.classList.add(CLASS.CAMERA);
229
+ sideState.forEach((state, i) => {
230
+ const panel = this.camera.children[i];
231
+ sidePanels += state.element.innerHTML;
232
+ Array.from(panel.attributes).forEach((attribute) =>
233
+ panel.removeAttribute(attribute.name)
234
+ );
235
+ });
236
+
237
+ sideCamera.innerHTML = sidePanels;
238
+
239
+ sideState.forEach((_, i) => {
240
+ const panel = this.camera.children[i];
241
+ [CLASS.VIEWPORT, CLASS.VERTICAL].forEach((className) => {
242
+ if (!panel.classList.contains(className)) {
243
+ panel.classList.add(className);
244
+ }
245
+ });
246
+ panel.innerHTML = sideCamera.outerHTML;
247
+ });
248
+
249
+ this.element.setAttribute("data-cross-structure", "true");
250
+ }
251
+
252
+ private _getGroupFromAttribute(
253
+ panels: HTMLElement[]
254
+ ): Record<string, HTMLElement[]> {
255
+ const groupKeys: string[] = [];
256
+ const groupPanels: Record<string, HTMLElement[]> = {};
257
+
258
+ panels.forEach((panel) => {
259
+ const groupKey = getDataAttributes(panel, "data-cross-").groupkey;
260
+ if (groupKey && !includes(groupKeys, groupKey)) {
261
+ groupKeys.push(groupKey);
262
+ groupPanels[groupKey] = [panel];
263
+ } else if (groupKey) {
264
+ groupPanels[groupKey].push(panel);
265
+ }
266
+ });
267
+
268
+ return groupPanels;
269
+ }
270
+
271
+ private _getSideStateFromGroup(
272
+ groupPanels: Record<string, HTMLElement[]>
273
+ ): SideState[] {
213
274
  return Object.keys(groupPanels).reduce(
214
275
  (state: SideState[], key: string) => {
215
276
  const start = state.length ? +state[state.length - 1].end + 1 : 0;
@@ -235,6 +296,24 @@ export class CrossFlicking extends Flicking {
235
296
  }
236
297
 
237
298
  private _getSideStateFromPanels(panels: HTMLElement[]): SideState[] {
299
+ return panels.reduce(
300
+ (state: SideState[], panel: HTMLElement, i: number) => {
301
+ const start = state.length ? +state[state.length - 1].end + 1 : 0;
302
+ return [
303
+ ...state,
304
+ {
305
+ key: i.toString(),
306
+ start,
307
+ end: start + panel.children.length - 1,
308
+ element: panel
309
+ }
310
+ ];
311
+ },
312
+ []
313
+ );
314
+ }
315
+
316
+ private _getSideStateFromCrossStructure(panels: HTMLElement[]): SideState[] {
238
317
  const groupPanels = this._getGroupFromAttribute(panels);
239
318
  return this._getSideStateFromGroup(groupPanels);
240
319
  }
@@ -245,13 +324,16 @@ export class CrossFlicking extends Flicking {
245
324
  ...this.sideOptions,
246
325
  horizontal: false,
247
326
  panelsPerView: 1,
248
- defaultIndex: state.start,
249
- moveType: "strict"
327
+ defaultIndex: state.start
250
328
  });
251
329
  });
252
330
  }
253
331
 
254
- private _syncToCategory(index: number, outerIndex: number): void {
332
+ private _syncToCategory = (index: number, outerIndex: number): void => {
333
+ if (this._disableIndexSync) {
334
+ return;
335
+ }
336
+
255
337
  this.stopAnimation();
256
338
  this._sideFlicking.forEach((child, i) => {
257
339
  const { start, end } = this._sideState[i];
@@ -262,18 +344,66 @@ export class CrossFlicking extends Flicking {
262
344
  void this.moveTo(i, 0);
263
345
  }
264
346
  });
265
- }
347
+ };
348
+
349
+ private _setDraggable = (
350
+ direction: ValueOf<typeof MOVE_DIRECTION>,
351
+ draggable: boolean
352
+ ): void => {
353
+ if (!this._disableSlideOnHold) {
354
+ return;
355
+ }
356
+
357
+ const dragThreshold = this._originalDragThreshold;
358
+ const threshold = draggable
359
+ ? dragThreshold && dragThreshold >= 10
360
+ ? dragThreshold
361
+ : 10
362
+ : Infinity;
363
+
364
+ if ((direction === MOVE_DIRECTION.HORIZONTAL) === this.horizontal) {
365
+ this.dragThreshold = threshold;
366
+ } else if ((direction === MOVE_DIRECTION.VERTICAL) === this.horizontal) {
367
+ this._sideFlicking.forEach((child) => {
368
+ child.dragThreshold = threshold;
369
+ });
370
+ }
371
+ };
372
+
373
+ private _setPreviousSideIndex = () => {
374
+ this._sideFlicking.forEach((child, i) => {
375
+ const { start, end } = this._sideState[i];
376
+
377
+ if (this._preserveIndex) {
378
+ if (this._nextIndex !== i) {
379
+ if (child.index < start) {
380
+ child.stopAnimation();
381
+ void child.moveTo(start, 0);
382
+ } else if (child.index > end) {
383
+ child.stopAnimation();
384
+ void child.moveTo(end, 0);
385
+ }
386
+ }
387
+ } else {
388
+ if (this._nextIndex !== i) {
389
+ void child.moveTo(start, 0);
390
+ }
391
+ }
392
+ });
393
+ };
394
+
395
+ private _addSideIndex = (e: ChangedEvent | WillChangeEvent): void => {
396
+ (e as CrossFlickingChangedEvent | CrossFlickingWillChangeEvent).sideIndex = this._sideFlicking[e.index].index;
397
+ };
266
398
 
267
399
  private _onHorizontalHoldStart = (): void => {
268
- this.dragThreshold = 10;
400
+ this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
269
401
  this._moveDirection = null;
270
402
  };
271
403
 
272
404
  private _onHorizontalMove = (e: MoveEvent): void => {
273
405
  if (e.isTrusted && !this._moveDirection) {
274
- this._sideFlicking.forEach((child) => {
275
- child.dragThreshold = Infinity;
276
- });
406
+ this._setDraggable(MOVE_DIRECTION.VERTICAL, false);
277
407
  this._moveDirection = MOVE_DIRECTION.HORIZONTAL;
278
408
  }
279
409
  };
@@ -281,11 +411,6 @@ export class CrossFlicking extends Flicking {
281
411
  private _onHorizontalMoveEnd = (e: MoveEndEvent): void => {
282
412
  const visiblePanels = this.visiblePanels;
283
413
 
284
- this._sideFlicking.forEach((child) => {
285
- child.dragThreshold = 10;
286
- });
287
- this._moveDirection = null;
288
-
289
414
  if (visiblePanels.length > 1) {
290
415
  this._nextIndex =
291
416
  e.direction === "NEXT"
@@ -295,22 +420,11 @@ export class CrossFlicking extends Flicking {
295
420
  this._nextIndex = visiblePanels[0].index;
296
421
  }
297
422
 
298
- // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 requestAnimationFrame 처리
299
- requestAnimationFrame(() => {
300
- this._sideFlicking.forEach((child, i) => {
301
- if (this._nextIndex !== i) {
302
- const { start, end } = this._sideState[i];
423
+ this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
424
+ this._moveDirection = null;
303
425
 
304
- if (child.index < start) {
305
- child.stopAnimation();
306
- void child.moveTo(start, 0);
307
- } else if (child.index > end) {
308
- child.stopAnimation();
309
- void child.moveTo(end, 0);
310
- }
311
- }
312
- });
313
- });
426
+ // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index 변하는 경우가 있어 requestAnimationFrame 처리
427
+ requestAnimationFrame(() => this._setPreviousSideIndex());
314
428
 
315
429
  if (e.isTrusted) {
316
430
  this._syncToCategory(
@@ -321,27 +435,25 @@ export class CrossFlicking extends Flicking {
321
435
  };
322
436
 
323
437
  private _onSideHoldStart = (): void => {
324
- this._sideFlicking.forEach((child) => {
325
- child.dragThreshold = 10;
326
- });
438
+ this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
327
439
  this._moveDirection = null;
328
440
  };
329
441
 
330
442
  private _onSideMove = (e: MoveEvent): void => {
331
443
  if (e.isTrusted && !this._moveDirection) {
332
- this.dragThreshold = Infinity;
444
+ this._setDraggable(MOVE_DIRECTION.HORIZONTAL, false);
333
445
  this._moveDirection = MOVE_DIRECTION.VERTICAL;
334
446
  }
335
447
  };
336
448
 
337
449
  private _onSideMoveEnd = (): void => {
338
- this.dragThreshold = 10;
450
+ this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
339
451
  this._moveDirection = null;
340
452
  };
341
453
 
342
454
  private _onSideChanged = (e: ChangedEvent): void => {
343
- // this.visiblePanels.length 2보다 크다면 가로 방향 Flicking이 조작 중이라는 것을 의미합니다.
344
- // 경우 가로 방향 Flicking의 이동이 완전히 끝난 _onHorizontalMoveEnd 에서 syncToCategory할 것이므로 여기서는 하지 않습니다.
455
+ // If this.visiblePanels.length >= 2, it means that horizontal flicking is being dragged.
456
+ // In this case, syncToCategory in _onHorizontalMoveEnd will fire after moving finishes, so we don't fire it here.
345
457
  if (
346
458
  this.visiblePanels.length < 2 &&
347
459
  this._sideFlicking[this.index] === e.currentTarget
package/src/Flicking.ts CHANGED
@@ -1739,7 +1739,7 @@ class Flicking extends Component<FlickingEvents> {
1739
1739
  if (!defaultPanel) return;
1740
1740
 
1741
1741
  const nearestAnchor = camera.findNearestAnchor(defaultPanel.position);
1742
- const initialPanel = (nearestAnchor && defaultPanel.index !== nearestAnchor.panel.index) ? nearestAnchor.panel : defaultPanel;
1742
+ const initialPanel = (nearestAnchor && defaultPanel.position !== nearestAnchor.panel.position && defaultPanel.index !== nearestAnchor.panel.index) ? nearestAnchor.panel : defaultPanel;
1743
1743
  control.setActive(initialPanel, null, false);
1744
1744
 
1745
1745
  if (!nearestAnchor) {
@@ -32,6 +32,7 @@ class Camera {
32
32
  private _mode: CameraMode;
33
33
  private _el: HTMLElement;
34
34
  private _transform: string;
35
+ private _lookedOffset = 0;
35
36
  private _position: number;
36
37
  private _alignPos: number;
37
38
  private _offset: number;
@@ -292,6 +293,8 @@ class Camera {
292
293
  * @return {this}
293
294
  */
294
295
  public lookAt(pos: number): void {
296
+ const prevOffset = this._offset;
297
+ const isChangedOffset = this._lookedOffset !== prevOffset;
295
298
  const flicking = getFlickingAttached(this._flicking);
296
299
  const prevPos = this._position;
297
300
 
@@ -304,7 +307,12 @@ class Camera {
304
307
  if (toggled) {
305
308
  void flicking.renderer.render().then(() => {
306
309
  this.updateOffset();
310
+ this._lookedOffset = this._offset;
307
311
  });
312
+ } else if (isChangedOffset) {
313
+ // sync offset for renderOnlyVisible on resize
314
+ this.updateOffset();
315
+ this._lookedOffset = this._offset;
308
316
  } else {
309
317
  this.applyTransform();
310
318
  }
@@ -502,8 +510,8 @@ class Camera {
502
510
  }
503
511
 
504
512
  /**
505
- * Update Viewport's height to active panel's height
506
- * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
513
+ * Update Viewport's height to visible panel's max height
514
+ * @ko 현재 활성화된 패널과 보이는 패널의 최대 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
507
515
  * @throws {FlickingError}
508
516
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
509
517
  * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
@@ -513,11 +521,22 @@ class Camera {
513
521
  public updateAdaptiveHeight() {
514
522
  const flicking = getFlickingAttached(this._flicking);
515
523
  const activePanel = flicking.control.activePanel;
524
+ const visiblePanels = flicking.visiblePanels;
525
+
526
+ const selectedPanels = [...visiblePanels];
527
+
528
+ if (activePanel) {
529
+ selectedPanels.push(activePanel);
530
+ }
531
+
532
+ if (!flicking.horizontal || !flicking.adaptive || !selectedPanels.length) return;
533
+
534
+
535
+ const maxHeight = Math.max(...selectedPanels.map(panel => panel.height));
516
536
 
517
- if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
518
537
 
519
538
  flicking.viewport.setSize({
520
- height: activePanel.height
539
+ height: maxHeight
521
540
  });
522
541
  }
523
542
 
@@ -599,6 +618,7 @@ class Camera {
599
618
 
600
619
  private _resetInternalValues() {
601
620
  this._position = 0;
621
+ this._lookedOffset = 0;
602
622
  this._alignPos = 0;
603
623
  this._offset = 0;
604
624
  this._circularOffset = 0;
@@ -39,6 +39,10 @@ class HoldingState extends State {
39
39
 
40
40
  const inputEvent = axesEvent.inputEvent as { offsetX: number; offsetY: number };
41
41
 
42
+ if (!inputEvent) {
43
+ return;
44
+ }
45
+
42
46
  const offset = flicking.horizontal
43
47
  ? inputEvent.offsetX
44
48
  : inputEvent.offsetY;