@egjs/flicking 4.15.0 → 4.16.0-beta.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 (185) hide show
  1. package/README.md +6 -175
  2. package/{declaration → dist}/CrossFlicking.d.ts +7 -2
  3. package/dist/Flicking.d.ts +1231 -0
  4. package/dist/camera/Camera.d.ts +324 -0
  5. package/{declaration → dist}/camera/mode/BoundCameraMode.d.ts +5 -4
  6. package/{declaration → dist}/camera/mode/CameraMode.d.ts +7 -6
  7. package/{declaration → dist}/camera/mode/CircularCameraMode.d.ts +9 -5
  8. package/{declaration → dist}/camera/mode/LinearCameraMode.d.ts +2 -4
  9. package/{declaration → dist}/cfc/getDefaultCameraTransform.d.ts +1 -1
  10. package/dist/cfc/withFlickingMethods.d.ts +15 -0
  11. package/{declaration/const/axes.d.ts → dist/constants/internal.d.ts} +8 -0
  12. package/dist/constants/values.d.ts +67 -0
  13. package/dist/control/AxesController.d.ts +186 -0
  14. package/dist/control/Control.d.ts +185 -0
  15. package/dist/control/FreeControl.d.ts +44 -0
  16. package/dist/control/SnapControl.d.ts +54 -0
  17. package/{declaration → dist}/control/StateMachine.d.ts +3 -0
  18. package/dist/control/StrictControl.d.ts +60 -0
  19. package/{declaration → dist}/control/states/AnimatingState.d.ts +12 -0
  20. package/{declaration → dist}/control/states/DisabledState.d.ts +12 -0
  21. package/{declaration → dist}/control/states/DraggingState.d.ts +12 -0
  22. package/{declaration → dist}/control/states/HoldingState.d.ts +12 -0
  23. package/{declaration → dist}/control/states/IdleState.d.ts +12 -0
  24. package/dist/control/states/State.d.ts +86 -0
  25. package/dist/core/AnchorPoint.d.ts +40 -0
  26. package/{declaration → dist}/core/AutoResizer.d.ts +6 -0
  27. package/dist/core/Viewport.d.ts +60 -0
  28. package/dist/core/VirtualManager.d.ts +84 -0
  29. package/dist/core/index.d.ts +6 -0
  30. package/dist/core/panel/Panel.d.ts +298 -0
  31. package/dist/core/panel/VirtualPanel.d.ts +41 -0
  32. package/dist/core/panel/index.d.ts +5 -0
  33. package/{declaration → dist}/core/panel/provider/VanillaElementProvider.d.ts +3 -0
  34. package/{declaration → dist}/core/panel/provider/VirtualElementProvider.d.ts +3 -0
  35. package/dist/error/FlickingError.d.ts +25 -0
  36. package/dist/error/codes.d.ts +79 -0
  37. package/dist/error/groups.d.ts +94 -0
  38. package/dist/error/index.d.ts +4 -0
  39. package/dist/error/types.d.ts +516 -0
  40. package/dist/event/groups.d.ts +40 -0
  41. package/dist/event/index.d.ts +3 -0
  42. package/dist/event/names.d.ts +47 -0
  43. package/dist/event/types.d.ts +318 -0
  44. package/dist/flicking.cjs.js +5559 -7791
  45. package/dist/flicking.cjs.js.map +1 -1
  46. package/dist/flicking.esm.js +5637 -7699
  47. package/dist/flicking.esm.js.map +1 -1
  48. package/dist/flicking.js +6722 -8893
  49. package/dist/flicking.js.map +1 -1
  50. package/dist/flicking.min.js +1 -9
  51. package/dist/flicking.min.js.map +1 -1
  52. package/dist/flicking.pkgd.js +9661 -14086
  53. package/dist/flicking.pkgd.js.map +1 -1
  54. package/dist/flicking.pkgd.min.js +1 -9
  55. package/dist/flicking.pkgd.min.js.map +1 -1
  56. package/dist/index.d.ts +16 -0
  57. package/dist/reactive/index.d.ts +126 -0
  58. package/{declaration → dist}/renderer/ExternalRenderer.d.ts +3 -0
  59. package/dist/renderer/Renderer.d.ts +215 -0
  60. package/{declaration → dist}/renderer/VanillaRenderer.d.ts +6 -0
  61. package/{declaration → dist}/renderer/strategy/NormalRenderingStrategy.d.ts +5 -2
  62. package/{declaration → dist}/renderer/strategy/RenderingStrategy.d.ts +4 -1
  63. package/dist/types/external.d.ts +58 -0
  64. package/dist/types/params.d.ts +10 -0
  65. package/{declaration → dist}/utils.d.ts +7 -7
  66. package/package.json +35 -162
  67. package/src/CrossFlicking.ts +68 -96
  68. package/src/Flicking.ts +1051 -972
  69. package/src/camera/Camera.ts +217 -206
  70. package/src/camera/index.ts +2 -6
  71. package/src/camera/mode/BoundCameraMode.ts +38 -27
  72. package/src/camera/mode/CameraMode.ts +14 -12
  73. package/src/camera/mode/CircularCameraMode.ts +24 -16
  74. package/src/camera/mode/LinearCameraMode.ts +3 -1
  75. package/src/camera/mode/index.ts +4 -10
  76. package/src/cfc/getDefaultCameraTransform.ts +9 -11
  77. package/src/cfc/getRenderingPanels.ts +2 -4
  78. package/src/cfc/index.ts +4 -9
  79. package/src/cfc/sync.ts +11 -5
  80. package/src/cfc/withFlickingMethods.ts +6 -7
  81. package/src/{const/axes.ts → constants/internal.ts} +1 -0
  82. package/src/constants/values.ts +78 -0
  83. package/src/control/AxesController.ts +119 -110
  84. package/src/control/Control.ts +147 -180
  85. package/src/control/FreeControl.ts +36 -60
  86. package/src/control/SnapControl.ts +64 -68
  87. package/src/control/StateMachine.ts +14 -11
  88. package/src/control/StrictControl.ts +58 -73
  89. package/src/control/index.ts +9 -12
  90. package/src/control/states/AnimatingState.ts +8 -11
  91. package/src/control/states/DisabledState.ts +0 -5
  92. package/src/control/states/DraggingState.ts +8 -12
  93. package/src/control/states/HoldingState.ts +10 -15
  94. package/src/control/states/IdleState.ts +1 -6
  95. package/src/control/states/State.ts +46 -85
  96. package/src/core/AnchorPoint.ts +25 -23
  97. package/src/core/AutoResizer.ts +6 -15
  98. package/src/core/ResizeWatcher.ts +17 -16
  99. package/src/core/Viewport.ts +35 -46
  100. package/src/core/VirtualManager.ts +48 -36
  101. package/src/core/index.ts +6 -9
  102. package/src/core/panel/Panel.ts +190 -185
  103. package/src/core/panel/VirtualPanel.ts +17 -21
  104. package/src/core/panel/index.ts +4 -9
  105. package/src/core/panel/provider/VanillaElementProvider.ts +6 -2
  106. package/src/core/panel/provider/VirtualElementProvider.ts +6 -2
  107. package/src/core/panel/provider/index.ts +2 -7
  108. package/src/{core → error}/FlickingError.ts +5 -7
  109. package/src/error/codes.ts +164 -0
  110. package/src/error/groups.ts +124 -0
  111. package/src/error/index.ts +9 -0
  112. package/src/error/types.ts +535 -0
  113. package/src/event/groups.ts +61 -0
  114. package/src/event/index.ts +8 -0
  115. package/src/event/names.ts +52 -0
  116. package/src/event/types.ts +355 -0
  117. package/src/index.ts +9 -11
  118. package/src/index.umd.ts +9 -3
  119. package/src/reactive/index.ts +39 -74
  120. package/src/renderer/Renderer.ts +170 -115
  121. package/src/renderer/VanillaRenderer.ts +12 -9
  122. package/src/renderer/index.ts +4 -9
  123. package/src/renderer/strategy/NormalRenderingStrategy.ts +26 -22
  124. package/src/renderer/strategy/RenderingStrategy.ts +2 -1
  125. package/src/renderer/strategy/VirtualRenderingStrategy.ts +20 -13
  126. package/src/renderer/strategy/index.ts +4 -9
  127. package/src/types/external.ts +72 -0
  128. package/src/{type → types}/internal.ts +2 -5
  129. package/src/types/params.ts +15 -0
  130. package/src/utils.ts +37 -32
  131. package/CONTRIBUTING.md +0 -59
  132. package/NOTICE +0 -31
  133. package/core-packages-link.js +0 -75
  134. package/debug/reactive/index.html +0 -240
  135. package/declaration/Flicking.d.ts +0 -264
  136. package/declaration/camera/Camera.d.ts +0 -90
  137. package/declaration/cfc/withFlickingMethods.d.ts +0 -2
  138. package/declaration/const/error.d.ts +0 -34
  139. package/declaration/const/external.d.ts +0 -54
  140. package/declaration/control/AxesController.d.ts +0 -45
  141. package/declaration/control/Control.d.ts +0 -45
  142. package/declaration/control/FreeControl.d.ts +0 -14
  143. package/declaration/control/SnapControl.d.ts +0 -16
  144. package/declaration/control/StrictControl.d.ts +0 -20
  145. package/declaration/control/states/State.d.ts +0 -47
  146. package/declaration/core/AnchorPoint.d.ts +0 -15
  147. package/declaration/core/FlickingError.d.ts +0 -5
  148. package/declaration/core/Viewport.d.ts +0 -25
  149. package/declaration/core/VirtualManager.d.ts +0 -37
  150. package/declaration/core/index.d.ts +0 -6
  151. package/declaration/core/panel/Panel.d.ts +0 -89
  152. package/declaration/core/panel/VirtualPanel.d.ts +0 -19
  153. package/declaration/core/panel/index.d.ts +0 -5
  154. package/declaration/index.d.ts +0 -16
  155. package/declaration/reactive/index.d.ts +0 -25
  156. package/declaration/renderer/Renderer.d.ts +0 -60
  157. package/declaration/type/event.d.ts +0 -88
  158. package/declaration/type/external.d.ts +0 -31
  159. package/jsconfig.json +0 -5
  160. package/jsdoc-to-mdx.json +0 -7
  161. package/rollup.config.demo.js +0 -24
  162. package/rollup.config.dev.js +0 -12
  163. package/rollup.config.js +0 -57
  164. package/src/const/error.ts +0 -64
  165. package/src/const/external.ts +0 -138
  166. package/src/type/event.ts +0 -315
  167. package/src/type/external.ts +0 -78
  168. package/tsconfig.declaration.json +0 -17
  169. package/tsconfig.eslint.json +0 -10
  170. package/tsconfig.json +0 -23
  171. package/{declaration → dist}/camera/index.d.ts +0 -0
  172. package/{declaration → dist}/camera/mode/index.d.ts +2 -2
  173. package/{declaration → dist}/cfc/getRenderingPanels.d.ts +0 -0
  174. package/{declaration → dist}/cfc/index.d.ts +3 -3
  175. package/{declaration → dist}/cfc/sync.d.ts +0 -0
  176. package/{declaration → dist}/control/index.d.ts +7 -7
  177. package/{declaration → dist}/core/ResizeWatcher.d.ts +0 -0
  178. package/{declaration → dist}/core/panel/provider/ElementProvider.d.ts +0 -0
  179. package/{declaration → dist}/core/panel/provider/index.d.ts +0 -0
  180. package/{declaration → dist}/index.cjs.d.ts +0 -0
  181. package/{declaration → dist}/index.umd.d.ts +0 -0
  182. package/{declaration → dist}/renderer/index.d.ts +1 -1
  183. package/{declaration → dist}/renderer/strategy/VirtualRenderingStrategy.d.ts +1 -1
  184. package/{declaration → dist}/renderer/strategy/index.d.ts +1 -1
  185. /package/{declaration/type → dist/types}/internal.d.ts +0 -0
@@ -0,0 +1,535 @@
1
+ /*
2
+ * Copyright (c) 2015 NAVER Corp.
3
+ * egjs projects are licensed under the MIT license
4
+ */
5
+
6
+ /**
7
+ * Documentation interface for Flicking error codes.
8
+ * @remarks
9
+ * This interface provides detailed documentation for each error code.
10
+ * Each property represents an error code with its numeric value and message signature.
11
+ * @public
12
+ * @see {@link ERROR_CODE} for usage in error handling
13
+ */
14
+ export interface FlickingErrors {
15
+ /**
16
+ * Parameter type is wrong.
17
+ * @remarks
18
+ * This error occurs when a method receives a parameter with an incorrect type.
19
+ * Common causes include:
20
+ *
21
+ * - Passing a number when a string is expected
22
+ *
23
+ * - Passing null/undefined to a required parameter
24
+ *
25
+ * - Passing a plain object when a specific instance is needed
26
+ *
27
+ * **Solution:** Check the method signature in the documentation and ensure you're passing
28
+ * the correct type for each parameter.
29
+ * @example
30
+ * ```typescript
31
+ * // ❌ Wrong - passing invalid type to align option
32
+ * new Flicking("#flicking", { align: 123 });
33
+ *
34
+ * // ✅ Correct
35
+ * new Flicking("#flicking", { align: "center" });
36
+ * ```
37
+ */
38
+ WRONG_TYPE: {
39
+ code: 0;
40
+ message: (wrongVal: any, correctTypes: string[]) => string;
41
+ };
42
+
43
+ /**
44
+ * Element is not found inside page with the given CSS selector.
45
+ * @remarks
46
+ * This error occurs during initialization when Flicking cannot find the specified element in the DOM.
47
+ * Common causes include:
48
+ *
49
+ * - CSS selector doesn't match any element
50
+ *
51
+ * - Element hasn't been rendered yet (timing issue)
52
+ *
53
+ * - Selector syntax error
54
+ *
55
+ * - Script runs before DOM is ready
56
+ *
57
+ * **Solution:** Ensure the target element exists in the DOM before creating a Flicking instance.
58
+ * Use `DOMContentLoaded` event or place your script at the end of the body.
59
+ * @example
60
+ * ```typescript
61
+ * // ❌ Wrong - element doesn't exist
62
+ * new Flicking("#non-existent");
63
+ *
64
+ * // ✅ Correct - check element exists first
65
+ * if (document.querySelector("#flicking")) {
66
+ * new Flicking("#flicking");
67
+ * }
68
+ *
69
+ * // ✅ Or wait for DOM ready
70
+ * document.addEventListener("DOMContentLoaded", () => {
71
+ * new Flicking("#flicking");
72
+ * });
73
+ * ```
74
+ * @see {@link Flicking.constructor}
75
+ */
76
+ ELEMENT_NOT_FOUND: {
77
+ code: 1;
78
+ message: (selector: string) => string;
79
+ };
80
+
81
+ /**
82
+ * Expected non-null value, but given `null` or `undefined`.
83
+ * @remarks
84
+ * This error occurs when a required parameter or property is null or undefined.
85
+ * Common causes include:
86
+ *
87
+ * - Passing null/undefined to a required parameter
88
+ *
89
+ * - Accessing a property before initialization
90
+ *
91
+ * - Using optional chaining incorrectly
92
+ *
93
+ * **Solution:** Ensure all required parameters have valid values before calling the method.
94
+ * @example
95
+ * ```typescript
96
+ * // ❌ Wrong - passing null to required parameter
97
+ * flicking.prepend(null);
98
+ *
99
+ * // ✅ Correct
100
+ * const element = document.createElement("div");
101
+ * flicking.prepend(element);
102
+ * ```
103
+ */
104
+ VAL_MUST_NOT_NULL: {
105
+ code: 2;
106
+ message: (val: any, name: string) => string;
107
+ };
108
+
109
+ /**
110
+ * Component is not attached to the Flicking instance.
111
+ * @remarks
112
+ * This error occurs when trying to use a Flicking component (Camera, Control, Renderer, etc.)
113
+ * before it has been properly initialized and attached to a Flicking instance.
114
+ * This is typically an internal error.
115
+ *
116
+ * **Solution:** Ensure the component's `init()` method has been called before using it.
117
+ * If you're creating custom components, make sure to call `init()` after instantiation.
118
+ * @example
119
+ * ```typescript
120
+ * const camera = new Camera();
121
+ * // ❌ Wrong - using camera before init
122
+ * camera.updateRange();
123
+ *
124
+ * // ✅ Correct - init first
125
+ * camera.init(flicking);
126
+ * camera.updateRange();
127
+ * ```
128
+ */
129
+ NOT_ATTACHED_TO_FLICKING: {
130
+ code: 3;
131
+ message: string;
132
+ };
133
+
134
+ /**
135
+ * One of the options is wrong.
136
+ * @remarks
137
+ * This error occurs when initializing Flicking with invalid option values.
138
+ * Common causes include:
139
+ *
140
+ * - Value is out of valid range
141
+ *
142
+ * - Value doesn't match expected enum/literal type
143
+ *
144
+ * - Invalid combination of options
145
+ *
146
+ * **Solution:** Check the documentation for the specific option and ensure the value
147
+ * meets all requirements (type, range, valid values, etc.).
148
+ * @example
149
+ * ```typescript
150
+ * // ❌ Wrong - invalid duration value
151
+ * new Flicking("#flicking", { duration: -100 });
152
+ *
153
+ * // ✅ Correct - positive duration
154
+ * new Flicking("#flicking", { duration: 500 });
155
+ *
156
+ * // ❌ Wrong - invalid moveType
157
+ * new Flicking("#flicking", { moveType: "invalid" });
158
+ *
159
+ * // ✅ Correct - use valid moveType
160
+ * new Flicking("#flicking", { moveType: "snap" });
161
+ * ```
162
+ * @see {@link FlickingOptions}
163
+ */
164
+ WRONG_OPTION: {
165
+ code: 4;
166
+ message: (optionName: string, val: any) => string;
167
+ };
168
+
169
+ /**
170
+ * The given index is out of possible range.
171
+ * @remarks
172
+ * This error occurs when trying to access a panel with an invalid index.
173
+ * Common causes include:
174
+ *
175
+ * - Index is negative
176
+ *
177
+ * - Index is greater than or equal to panel count
178
+ *
179
+ * - Trying to access panels when there are none
180
+ *
181
+ * **Solution:** Ensure the index is within the valid range [0, panelCount - 1].
182
+ * Check `flicking.panelCount` before accessing panels by index.
183
+ * @example
184
+ * ```typescript
185
+ * const flicking = new Flicking("#flicking");
186
+ *
187
+ * // ❌ Wrong - negative index
188
+ * flicking.moveTo(-1);
189
+ *
190
+ * // ❌ Wrong - index too large
191
+ * flicking.moveTo(999);
192
+ *
193
+ * // ✅ Correct - check valid range first
194
+ * const targetIndex = 5;
195
+ * if (targetIndex >= 0 && targetIndex < flicking.panelCount) {
196
+ * flicking.moveTo(targetIndex);
197
+ * }
198
+ * ```
199
+ * @see {@link Flicking.moveTo}
200
+ * @see {@link Flicking.panelCount}
201
+ */
202
+ INDEX_OUT_OF_RANGE: {
203
+ code: 5;
204
+ message: (val: number, min: number, max: number) => string;
205
+ };
206
+
207
+ /**
208
+ * Position parameter is out of possible range.
209
+ * @remarks
210
+ * This error occurs when trying to move the camera to an unreachable position.
211
+ * The valid position range depends on:
212
+ *
213
+ * - Number of panels
214
+ *
215
+ * - Panel sizes
216
+ *
217
+ * - Circular mode setting
218
+ *
219
+ * - Bound setting
220
+ *
221
+ * **Solution:** Use `camera.range` to check the valid position range before moving.
222
+ * Alternatively, use index-based methods like `moveTo()` instead of position-based methods.
223
+ * @example
224
+ * ```typescript
225
+ * const flicking = new Flicking("#flicking");
226
+ *
227
+ * // ❌ Wrong - position out of range
228
+ * flicking.control.moveToPosition(99999, 0);
229
+ *
230
+ * // ✅ Correct - check range first
231
+ * const { min, max } = flicking.camera.range;
232
+ * const targetPos = 500;
233
+ * if (targetPos >= min && targetPos <= max) {
234
+ * flicking.control.moveToPosition(targetPos, 0);
235
+ * }
236
+ *
237
+ * // ✅ Or use index-based method
238
+ * flicking.moveTo(2);
239
+ * ```
240
+ * @see {@link Control.moveToPosition}
241
+ * @see {@link Camera.range}
242
+ */
243
+ POSITION_NOT_REACHABLE: {
244
+ code: 6;
245
+ message: (position: number) => string;
246
+ };
247
+
248
+ /**
249
+ * CSS `transform` property is not available.
250
+ * @remarks
251
+ * This error occurs when initializing Flicking in a browser that doesn't support
252
+ * CSS transforms (IE8 and below). Flicking requires CSS transform support to function.
253
+ *
254
+ * **Solution:** Use a modern browser or polyfill CSS transforms. Alternatively,
255
+ * display a fallback message for unsupported browsers.
256
+ * @example
257
+ * ```typescript
258
+ * // Check transform support before initialization
259
+ * const supportsTransform = 'transform' in document.createElement('div').style;
260
+ *
261
+ * if (supportsTransform) {
262
+ * new Flicking("#flicking");
263
+ * } else {
264
+ * console.error("Your browser doesn't support CSS transforms");
265
+ * }
266
+ * ```
267
+ */
268
+ TRANSFORM_NOT_SUPPORTED: {
269
+ code: 7;
270
+ message: string;
271
+ };
272
+
273
+ /**
274
+ * The event's `stop()` method was called by user.
275
+ * @remarks
276
+ * This is not an actual error, but a signal that the user intentionally stopped
277
+ * an operation by calling `event.stop()` in an event handler. This "error" is used
278
+ * to halt the operation flow.
279
+ *
280
+ * Common scenarios:
281
+ *
282
+ * - Preventing panel change in `willChange` event
283
+ *
284
+ * - Canceling animation in `moveStart` event
285
+ *
286
+ * - Conditional navigation based on validation
287
+ *
288
+ * **Solution:** This is expected behavior. Catch this error if you need to handle
289
+ * user-initiated cancellations differently from actual errors.
290
+ * @example
291
+ * ```typescript
292
+ * flicking.on("willChange", e => {
293
+ * if (!isValidTransition(e.index)) {
294
+ * e.stop(); // This throws STOP_CALLED_BY_USER error
295
+ * }
296
+ * });
297
+ *
298
+ * try {
299
+ * await flicking.next();
300
+ * } catch (err) {
301
+ * if (err.code === ERROR_CODE.STOP_CALLED_BY_USER) {
302
+ * console.log("User prevented navigation");
303
+ * }
304
+ * }
305
+ * ```
306
+ * @see {@link WillChangeEvent}
307
+ * @see {@link WillRestoreEvent}
308
+ */
309
+ STOP_CALLED_BY_USER: {
310
+ code: 8;
311
+ message: string;
312
+ };
313
+
314
+ /**
315
+ * The animation was interrupted by user input.
316
+ * @remarks
317
+ * This error occurs when an ongoing animation is interrupted by user interaction
318
+ * (mouse/touch input) or by calling another animation method.
319
+ *
320
+ * Common causes:
321
+ *
322
+ * - User starts dragging during animation
323
+ *
324
+ * - Calling `moveTo()` while previous `moveTo()` is animating
325
+ *
326
+ * - User clicks/touches the viewport during transition
327
+ *
328
+ * **Solution:** This is normal behavior and usually doesn't need special handling.
329
+ * If you need to ensure animation completes, use `interruptable: false` option
330
+ * or prevent user input during animation.
331
+ * @example
332
+ * ```typescript
333
+ * try {
334
+ * await flicking.next();
335
+ * } catch (err) {
336
+ * if (err.code === ERROR_CODE.ANIMATION_INTERRUPTED) {
337
+ * console.log("Animation was interrupted");
338
+ * }
339
+ * }
340
+ *
341
+ * // Prevent interruption with interruptable option
342
+ * flicking.next({ interruptable: false });
343
+ * ```
344
+ * @see {@link Flicking.next}
345
+ * @see {@link Flicking.prev}
346
+ * @see {@link Flicking.moveTo}
347
+ */
348
+ ANIMATION_INTERRUPTED: {
349
+ code: 9;
350
+ message: string;
351
+ };
352
+
353
+ /**
354
+ * An animation is already playing.
355
+ * @remarks
356
+ * This error occurs when trying to start a new animation while another animation
357
+ * is currently in progress, and the new animation is not allowed to interrupt.
358
+ *
359
+ * Common causes:
360
+ *
361
+ * - Calling `moveTo()` rapidly in succession
362
+ *
363
+ * - Using `interruptable: false` option
364
+ *
365
+ * - Programmatic navigation during user-initiated animation
366
+ *
367
+ * **Solution:** Wait for the current animation to finish, or allow interruption
368
+ * by not using `interruptable: false` option.
369
+ * @example
370
+ * ```typescript
371
+ * // ❌ Wrong - trying to animate while animation is in progress
372
+ * flicking.next({ interruptable: false });
373
+ * flicking.prev(); // Throws ANIMATION_ALREADY_PLAYING
374
+ *
375
+ * // ✅ Correct - wait for animation to finish
376
+ * await flicking.next({ interruptable: false });
377
+ * await flicking.prev();
378
+ *
379
+ * // ✅ Or check if animating
380
+ * if (!flicking.animating) {
381
+ * flicking.next();
382
+ * }
383
+ * ```
384
+ * @see {@link Flicking.animating}
385
+ */
386
+ ANIMATION_ALREADY_PLAYING: {
387
+ code: 10;
388
+ message: string;
389
+ };
390
+
391
+ /**
392
+ * The method is not allowed in framework components.
393
+ * @remarks
394
+ * This error occurs when calling methods that manipulate the DOM directly
395
+ * (like `insert`, `remove`, `replace`) from framework components (React, Vue, Angular).
396
+ * In frameworks, DOM manipulation should be handled by the framework itself.
397
+ *
398
+ * **Solution:** Use the framework's built-in methods to manipulate the component tree.
399
+ * Let the framework handle panel additions/removals through its reactive system.
400
+ * @example
401
+ * ```typescript
402
+ * // ❌ Wrong - in React component
403
+ * flicking.append("<div>New Panel</div>");
404
+ *
405
+ * // ✅ Correct - use React state
406
+ * const [panels, setPanels] = useState([...]);
407
+ * setPanels([...panels, newPanel]);
408
+ *
409
+ * // Render with framework
410
+ * <Flicking>
411
+ * {panels.map(panel => <div key={panel.id}>{panel.content}</div>)}
412
+ * </Flicking>
413
+ * ```
414
+ * @see {@link Flicking.insert}
415
+ * @see {@link Flicking.remove}
416
+ * @see {@link Flicking.replace}
417
+ */
418
+ NOT_ALLOWED_IN_FRAMEWORK: {
419
+ code: 11;
420
+ message: string;
421
+ };
422
+
423
+ /**
424
+ * Flicking is not initialized yet.
425
+ * @remarks
426
+ * This error occurs when calling methods that require Flicking to be fully initialized,
427
+ * before `init()` has been called or completed.
428
+ *
429
+ * Common causes:
430
+ *
431
+ * - Calling methods immediately after `new Flicking()` without waiting
432
+ *
433
+ * - Using methods before async initialization completes
434
+ *
435
+ * - Accessing Flicking instance before mount in frameworks
436
+ *
437
+ * **Solution:** Wait for the `ready` event or ensure `init()` has completed
438
+ * before calling other methods.
439
+ * @example
440
+ * ```typescript
441
+ * const flicking = new Flicking("#flicking");
442
+ *
443
+ * // ❌ Wrong - calling before initialization
444
+ * flicking.next();
445
+ *
446
+ * // ✅ Correct - wait for ready event
447
+ * flicking.on("ready", () => {
448
+ * flicking.next();
449
+ * });
450
+ *
451
+ * // ✅ Or use async/await
452
+ * await flicking.init();
453
+ * flicking.next();
454
+ * ```
455
+ * @see {@link Flicking.init}
456
+ * @see {@link ReadyEvent}
457
+ */
458
+ NOT_INITIALIZED: {
459
+ code: 12;
460
+ message: string;
461
+ };
462
+
463
+ /**
464
+ * There is no active panel.
465
+ * @remarks
466
+ * This error occurs when trying to access or operate on the active panel,
467
+ * but Flicking has no panels or hasn't selected an active panel yet.
468
+ *
469
+ * Common causes:
470
+ *
471
+ * - Initializing Flicking with an empty container
472
+ *
473
+ * - Removing all panels at runtime
474
+ *
475
+ * - Accessing `currentPanel` before initialization
476
+ *
477
+ * **Solution:** Ensure Flicking has at least one panel, or check for the
478
+ * existence of an active panel before accessing it.
479
+ * @example
480
+ * ```typescript
481
+ * // ❌ Wrong - no panels in container
482
+ * const flicking = new Flicking("#empty-flicking");
483
+ * console.log(flicking.currentPanel); // Throws NO_ACTIVE
484
+ *
485
+ * // ✅ Correct - check panel count first
486
+ * if (flicking.panelCount > 0) {
487
+ * console.log(flicking.currentPanel);
488
+ * }
489
+ *
490
+ * // ✅ Or use optional chaining
491
+ * const currentIndex = flicking.currentPanel?.index ?? -1;
492
+ * ```
493
+ * @see {@link Flicking.currentPanel}
494
+ * @see {@link Flicking.panelCount}
495
+ */
496
+ NO_ACTIVE: {
497
+ code: 13;
498
+ message: string;
499
+ };
500
+
501
+ /**
502
+ * The method is not allowed when the virtual option is enabled.
503
+ * @remarks
504
+ * This error occurs when calling DOM manipulation methods (`insert`, `remove`, `replace`)
505
+ * while the `virtual` option is enabled. Virtual mode manages panels differently,
506
+ * and direct DOM manipulation would break its internal state.
507
+ *
508
+ * **Solution:** Use Flicking's `renderPanel` callback to manage panel content in virtual mode,
509
+ * or disable virtual mode if you need direct DOM manipulation.
510
+ * @example
511
+ * ```typescript
512
+ * const flicking = new Flicking("#flicking", {
513
+ * virtual: true
514
+ * });
515
+ *
516
+ * // ❌ Wrong - DOM manipulation in virtual mode
517
+ * flicking.append("<div>New Panel</div>");
518
+ *
519
+ * // ✅ Correct - use renderPanel callback
520
+ * const flicking = new Flicking("#flicking", {
521
+ * virtual: {
522
+ * renderPanel: (panel, index) => {
523
+ * return `<div>Panel ${index}</div>`;
524
+ * }
525
+ * }
526
+ * });
527
+ * ```
528
+ * @see {@link Flicking.insert}
529
+ * @see {@link VirtualManager}
530
+ */
531
+ NOT_ALLOWED_IN_VIRTUAL: {
532
+ code: 14;
533
+ message: string;
534
+ };
535
+ }
@@ -0,0 +1,61 @@
1
+ /*
2
+ * Copyright (c) 2015 NAVER Corp.
3
+ * egjs projects are licensed under the MIT license
4
+ */
5
+
6
+ /**
7
+ * Event groups for documentation purposes.
8
+ * These interfaces are not used at runtime but serve as centralized documentation
9
+ * for events fired by related methods.
10
+ */
11
+
12
+ import type {
13
+ AfterResizeEvent,
14
+ BeforeResizeEvent,
15
+ ChangedEvent,
16
+ MoveEndEvent,
17
+ MoveEvent,
18
+ MoveStartEvent,
19
+ NeedPanelEvent,
20
+ ReachEdgeEvent,
21
+ RestoredEvent,
22
+ VisibleChangeEvent,
23
+ WillChangeEvent,
24
+ WillRestoreEvent
25
+ } from "./types";
26
+
27
+ /**
28
+ * Events fired during panel movement operations (prev, next, moveTo).
29
+ */
30
+ export interface MovementEvents {
31
+ /** see {@link WillChangeEvent} */
32
+ willChange: WillChangeEvent;
33
+ /** see {@link ChangedEvent} */
34
+ changed: ChangedEvent;
35
+ /** see {@link WillRestoreEvent} */
36
+ willRestore: WillRestoreEvent;
37
+ /** see {@link RestoredEvent} */
38
+ restored: RestoredEvent;
39
+ /** see {@link MoveStartEvent} */
40
+ moveStart: MoveStartEvent;
41
+ /** see {@link MoveEvent} */
42
+ move: MoveEvent;
43
+ /** see {@link MoveEndEvent} */
44
+ moveEnd: MoveEndEvent;
45
+ /** see {@link NeedPanelEvent} */
46
+ needPanel: NeedPanelEvent;
47
+ /** see {@link VisibleChangeEvent} */
48
+ visibleChange: VisibleChangeEvent;
49
+ /** see {@link ReachEdgeEvent} */
50
+ reachEdge: ReachEdgeEvent;
51
+ }
52
+
53
+ /**
54
+ * Events fired during resize operations.
55
+ */
56
+ export interface ResizeEvents {
57
+ /** see {@link BeforeResizeEvent} */
58
+ beforeResize: BeforeResizeEvent;
59
+ /** see {@link AfterResizeEvent} */
60
+ afterResize: AfterResizeEvent;
61
+ }
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright (c) 2015 NAVER Corp.
3
+ * egjs projects are licensed under the MIT license
4
+ */
5
+
6
+ export * from "./groups";
7
+ export { EVENTS } from "./names";
8
+ export * from "./types";
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Copyright (c) 2015 NAVER Corp.
3
+ * egjs projects are licensed under the MIT license
4
+ */
5
+
6
+ /**
7
+ * Event type object with event name strings of {@link Flicking}
8
+ * @example
9
+ * ```ts
10
+ * import { EVENTS } from "@egjs/flicking";
11
+ * EVENTS.MOVE_START; // "moveStart"
12
+ * ```
13
+ */
14
+ export const EVENTS = {
15
+ /** ready event */
16
+ READY: "ready",
17
+ /** beforeResize event */
18
+ BEFORE_RESIZE: "beforeResize",
19
+ /** afterResize event */
20
+ AFTER_RESIZE: "afterResize",
21
+ /** holdStart event */
22
+ HOLD_START: "holdStart",
23
+ /** holdEnd event */
24
+ HOLD_END: "holdEnd",
25
+ /** moveStart event */
26
+ MOVE_START: "moveStart",
27
+ /** move event */
28
+ MOVE: "move",
29
+ /** moveEnd event */
30
+ MOVE_END: "moveEnd",
31
+ /** willChange event */
32
+ WILL_CHANGE: "willChange",
33
+ /** changed event */
34
+ CHANGED: "changed",
35
+ /** willRestore event */
36
+ WILL_RESTORE: "willRestore",
37
+ /** restored event */
38
+ RESTORED: "restored",
39
+ /** select event */
40
+ SELECT: "select",
41
+ /** needPanel event */
42
+ NEED_PANEL: "needPanel",
43
+ /** visibleChange event */
44
+ VISIBLE_CHANGE: "visibleChange",
45
+ /** reachEdge event */
46
+ REACH_EDGE: "reachEdge",
47
+ /**
48
+ * panelChange event
49
+ * @since 4.1.0
50
+ */
51
+ PANEL_CHANGE: "panelChange"
52
+ } as const;