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