@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,355 @@
1
+ /* eslint-disable @typescript-eslint/ban-types */
2
+ /*
3
+ * Copyright (c) 2015 NAVER Corp.
4
+ * egjs projects are licensed under the MIT license
5
+ */
6
+ import { OnChange, OnFinish, OnHold, OnRelease } from "@egjs/axes";
7
+ import { ComponentEvent } from "@egjs/component";
8
+ import { DIRECTION } from "../constants/values";
9
+ import Panel from "../core/panel/Panel";
10
+ import Flicking from "../Flicking";
11
+ import { ValueOf } from "../types/internal";
12
+
13
+ import { EVENTS } from "./names";
14
+
15
+ /**
16
+ * Events of the Flicking component.
17
+ * @privateRemarks
18
+ * This interface is crucial as it maps event names to their actual event interfaces.
19
+ * It is also functionally important because it is registered as the event generic parameter of Component, which is Flicking's parent class.
20
+ */
21
+ export interface FlickingEvents {
22
+ /**
23
+ * Event that fires when Flicking's {@link Flicking.init | init()} is called.
24
+ * @remarks
25
+ * See {@link ReadyEvent} for more details.
26
+ */
27
+ [EVENTS.READY]: ReadyEvent;
28
+ /**
29
+ * Event that fires when Flicking's {@link Flicking.resize} is called, before updating the sizes of panels and viewport.
30
+ * @remarks
31
+ * See {@link BeforeResizeEvent} for more details.
32
+ */
33
+ [EVENTS.BEFORE_RESIZE]: BeforeResizeEvent;
34
+ /**
35
+ * Event that fires when Flicking's {@link Flicking.resize} is called, after updating the sizes of panels and viewport.
36
+ * @remarks
37
+ * See {@link AfterResizeEvent} for more details.
38
+ */
39
+ [EVENTS.AFTER_RESIZE]: AfterResizeEvent;
40
+ /**
41
+ * Event that fires when user started dragging.
42
+ * @remarks
43
+ * See {@link HoldStartEvent} for more details.
44
+ */
45
+ [EVENTS.HOLD_START]: HoldStartEvent;
46
+ /**
47
+ * Event that fires when user stopped dragging.
48
+ * @remarks
49
+ * See {@link HoldEndEvent} for more details.
50
+ */
51
+ [EVENTS.HOLD_END]: HoldEndEvent;
52
+ /**
53
+ * Event that fires once before first {@link Flicking.event:move | move} event.
54
+ * @remarks
55
+ * See {@link MoveStartEvent} for more details.
56
+ */
57
+ [EVENTS.MOVE_START]: MoveStartEvent;
58
+ /**
59
+ * Event that fires for every movement.
60
+ * @remarks
61
+ * See {@link MoveEvent} for more details.
62
+ */
63
+ [EVENTS.MOVE]: MoveEvent;
64
+ /**
65
+ * Event that fires when the movement is finished by user input release or animation end.
66
+ * @remarks
67
+ * See {@link MoveEndEvent} for more details.
68
+ */
69
+ [EVENTS.MOVE_END]: MoveEndEvent;
70
+ /**
71
+ * Event that fires BEFORE the active panel changes.
72
+ * @remarks
73
+ * See {@link WillChangeEvent} for more details.
74
+ */
75
+ [EVENTS.WILL_CHANGE]: WillChangeEvent;
76
+ /**
77
+ * Event that fires AFTER the active panel change completes.
78
+ * @remarks
79
+ * See {@link ChangedEvent} for more details.
80
+ */
81
+ [EVENTS.CHANGED]: ChangedEvent;
82
+ /**
83
+ * Event fires BEFORE returning to the current panel when drag doesn't reach threshold.
84
+ * @remarks
85
+ * See {@link WillRestoreEvent} for more details.
86
+ */
87
+ [EVENTS.WILL_RESTORE]: WillRestoreEvent;
88
+ /**
89
+ * Event that fires AFTER Flicking has returned to {@link Flicking.currentPanel | currentPanel}.
90
+ * @remarks
91
+ * See {@link RestoredEvent} for more details.
92
+ */
93
+ [EVENTS.RESTORED]: RestoredEvent;
94
+ /**
95
+ * Event that fires when panel is statically click / touched.
96
+ * @remarks
97
+ * See {@link SelectEvent} for more details.
98
+ */
99
+ [EVENTS.SELECT]: SelectEvent;
100
+ /**
101
+ * Event that fires when an empty panel area is visible at the edge of viewport.
102
+ * @remarks
103
+ * See {@link NeedPanelEvent} for more details.
104
+ */
105
+ [EVENTS.NEED_PANEL]: NeedPanelEvent;
106
+ /**
107
+ * Event that fires when visible panel inside the viewport changes.
108
+ * @remarks
109
+ * See {@link VisibleChangeEvent} for more details.
110
+ */
111
+ [EVENTS.VISIBLE_CHANGE]: VisibleChangeEvent;
112
+ /**
113
+ * Event that fires when camera reaches the maximum/minimum range.
114
+ * @remarks
115
+ * See {@link ReachEdgeEvent} for more details.
116
+ */
117
+ [EVENTS.REACH_EDGE]: ReachEdgeEvent;
118
+ /**
119
+ * Event that fires when a panel is added or removed.
120
+ * @since 4.1.0
121
+ * @remarks
122
+ * See {@link PanelChangeEvent} for more details.
123
+ */
124
+ [EVENTS.PANEL_CHANGE]: PanelChangeEvent;
125
+ }
126
+
127
+ /**
128
+ * Event that fires when Flicking's {@link Flicking.init | init()} is called
129
+ */
130
+ export type ReadyEvent<T extends Flicking = Flicking> = ComponentEvent<{}, (typeof EVENTS)["READY"], T>;
131
+
132
+ /**
133
+ * Event that fires when Flicking's {@link Flicking.resize} is called, before updating the sizes of panels and viewport.
134
+ * @remarks
135
+ * You can update the sizes of panels and viewport with this event, and it'll be applied after {@link Flicking.resize} is finished.
136
+ */
137
+ export interface BeforeResizeEvent<T extends Flicking = Flicking>
138
+ extends ComponentEvent<{}, (typeof EVENTS)["BEFORE_RESIZE"], T> {
139
+ /** Previous width of the viewport */
140
+ width: number;
141
+ /** Previous height of the viewport */
142
+ height: number;
143
+ /** The viewport element */
144
+ element: HTMLElement;
145
+ }
146
+
147
+ /**
148
+ * Event that fires when Flicking's {@link Flicking.resize} is called, after updating the sizes of panels and viewport.
149
+ */
150
+ export interface AfterResizeEvent<T extends Flicking = Flicking>
151
+ extends ComponentEvent<{}, (typeof EVENTS)["AFTER_RESIZE"], T> {
152
+ /** New width of the viewport */
153
+ width: number;
154
+ /** New height of the viewport */
155
+ height: number;
156
+ /** Previous size of the viewport */
157
+ prev: {
158
+ /** Previous width of the viewport */
159
+ width: number;
160
+ /** Previous height of the viewport */
161
+ height: number;
162
+ };
163
+ /** A Boolean value indicating whether the width/height of the viewport element is changed */
164
+ sizeChanged: boolean;
165
+ /** The viewport element */
166
+ element: HTMLElement;
167
+ }
168
+
169
+ /**
170
+ * Event that fires when user started dragging.
171
+ */
172
+ export interface HoldStartEvent<T extends Flicking = Flicking>
173
+ extends ComponentEvent<{}, (typeof EVENTS)["HOLD_START"], T> {
174
+ /** {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-hold | hold} event of {@link https://naver.github.io/egjs-axes/ | Axes} */
175
+ axesEvent: OnHold;
176
+ }
177
+
178
+ /**
179
+ * Event that fires when user stopped dragging.
180
+ */
181
+ export interface HoldEndEvent<T extends Flicking = Flicking>
182
+ extends ComponentEvent<{}, (typeof EVENTS)["HOLD_END"], T> {
183
+ /** {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-release | release} event of {@link https://naver.github.io/egjs-axes/ | Axes} */
184
+ axesEvent: OnRelease;
185
+ }
186
+
187
+ /**
188
+ * Event that fires once before first {@link Flicking.event:move | move} event
189
+ */
190
+ export interface MoveStartEvent<T extends Flicking = Flicking>
191
+ extends ComponentEvent<{}, (typeof EVENTS)["MOVE_START"], T> {
192
+ /** Boolean that indicates whether the event was generated by a user action */
193
+ isTrusted: boolean;
194
+ /** Boolean that indicates whether the user is dragging the viewport element */
195
+ holding: boolean;
196
+ /** Moving direction relative to previous position of the camera */
197
+ direction: ValueOf<typeof DIRECTION>;
198
+ /** {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-change | change} event of {@link https://naver.github.io/egjs-axes/ | Axes} */
199
+ axesEvent: OnChange;
200
+ }
201
+
202
+ /**
203
+ * Event that fires for every movement
204
+ */
205
+ export interface MoveEvent<T extends Flicking = Flicking> extends ComponentEvent<{}, (typeof EVENTS)["MOVE"], T> {
206
+ /** Boolean that indicates whether the event was generated by a user action */
207
+ isTrusted: boolean;
208
+ /** Boolean that indicates whether the user is dragging the viewport element */
209
+ holding: boolean;
210
+ /** Moving direction relative to previous position of the camera */
211
+ direction: ValueOf<typeof DIRECTION>;
212
+ /** {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-change | change} event of {@link https://naver.github.io/egjs-axes/ | Axes} */
213
+ axesEvent: OnChange;
214
+ }
215
+
216
+ /**
217
+ * Event that fires when the movement is finished by user input release or animation end.
218
+ */
219
+ export interface MoveEndEvent<T extends Flicking = Flicking>
220
+ extends ComponentEvent<{}, (typeof EVENTS)["MOVE_END"], T> {
221
+ /** Boolean that indicates whether the event was generated by a user action */
222
+ isTrusted: boolean;
223
+ /** Moving direction relative to previous position of the camera */
224
+ direction: ValueOf<typeof DIRECTION>;
225
+ /** {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-finish | finish} event of {@link https://naver.github.io/egjs-axes/ | Axes} */
226
+ axesEvent: OnFinish;
227
+ }
228
+
229
+ /**
230
+ * Event that fires BEFORE the active panel changes.
231
+ * @remarks
232
+ * Index will be changed at the {@link ChangedEvent | changed} event.
233
+ * It can be triggered when user finished input, or flicking start to move by method.
234
+ * Calling `stop()` in event will prevent index change and camera movement.
235
+ * @see {@link ChangedEvent} - Fired AFTER the panel change completes
236
+ */
237
+ export interface WillChangeEvent<T extends Flicking = Flicking>
238
+ extends ComponentEvent<{}, (typeof EVENTS)["WILL_CHANGE"], T> {
239
+ /** New active index */
240
+ index: number;
241
+ /** New active panel */
242
+ panel: Panel;
243
+ /** Boolean that indicates whether the event was generated by a user action */
244
+ isTrusted: boolean;
245
+ /** Moving direction from the active panel to the target panel */
246
+ direction: ValueOf<typeof DIRECTION>;
247
+ }
248
+
249
+ /**
250
+ * Event that fires AFTER the active panel change completes.
251
+ * @remarks
252
+ * This event fires after the panel movement animation finishes and the index is updated.
253
+ * @see {@link WillChangeEvent} - Fired BEFORE the panel change starts
254
+ */
255
+ export interface ChangedEvent<T extends Flicking = Flicking> extends ComponentEvent<{}, (typeof EVENTS)["CHANGED"], T> {
256
+ /** New index */
257
+ index: number;
258
+ /** New active panel */
259
+ panel: Panel;
260
+ /** Previous index */
261
+ prevIndex: number;
262
+ /** Previous active panel */
263
+ prevPanel: Panel | null;
264
+ /** Boolean that indicates whether the event was generated by a user action */
265
+ isTrusted: boolean;
266
+ /** Moving direction from the active panel to the target panel */
267
+ direction: ValueOf<typeof DIRECTION>;
268
+ }
269
+
270
+ /**
271
+ * Event fires BEFORE returning to the current panel when drag doesn't reach threshold.
272
+ * @remarks
273
+ * Fired when user drag amount does not reach {@link Flicking.threshold | threshold} and the camera starts returning to {@link Flicking.currentPanel | currentPanel}.
274
+ * @see {@link RestoredEvent} - Fired AFTER restoration completes
275
+ */
276
+ export interface WillRestoreEvent<T extends Flicking = Flicking>
277
+ extends ComponentEvent<{}, (typeof EVENTS)["WILL_RESTORE"], T> {
278
+ /** Index of the panel to restore */
279
+ index: number;
280
+ /** Panel to restore */
281
+ panel: Panel;
282
+ /** Boolean that indicates whether the event was generated by a user action */
283
+ isTrusted: boolean;
284
+ /** Moving direction relative to previous position of the camera */
285
+ direction: ValueOf<typeof DIRECTION>;
286
+ }
287
+
288
+ /**
289
+ * Event that fires AFTER Flicking has returned to {@link Flicking.currentPanel | currentPanel}.
290
+ * @remarks
291
+ * Fired after the restoration animation completes and the camera has returned to the current panel.
292
+ * @see {@link WillRestoreEvent} - Fired BEFORE restoration starts
293
+ */
294
+ export interface RestoredEvent<T extends Flicking = Flicking>
295
+ extends ComponentEvent<{}, (typeof EVENTS)["RESTORED"], T> {
296
+ /** Boolean that indicates whether the event was generated by a user action */
297
+ isTrusted: boolean;
298
+ }
299
+
300
+ /**
301
+ * Event that fires when panel is statically click / touched
302
+ */
303
+ export interface SelectEvent<T extends Flicking = Flicking> extends ComponentEvent<{}, (typeof EVENTS)["SELECT"], T> {
304
+ /** Selected panel's index */
305
+ index: number;
306
+ /** Selected panel */
307
+ panel: Panel;
308
+ /** Direction from current camera position to the selected panel's position */
309
+ direction: ValueOf<typeof DIRECTION> | null;
310
+ }
311
+
312
+ /**
313
+ * Event that fires when an empty panel area is visible at the edge of viewport
314
+ * @remarks
315
+ * You can set its threshold with {@link Flicking.needPanelThreshold | needPanelThreshold}
316
+ */
317
+ export interface NeedPanelEvent<T extends Flicking = Flicking>
318
+ extends ComponentEvent<{}, (typeof EVENTS)["NEED_PANEL"], T> {
319
+ /** Direction where new panel is needed. `DIRECTION.PREV` means panels should be {@link Flicking.prepend | prepend}ed and `DIRECTION.NEXT` means panels should be {@link Flicking.append | append}ed */
320
+ direction: Exclude<ValueOf<typeof DIRECTION>, null>;
321
+ }
322
+
323
+ /**
324
+ * Event that fires when visible panel inside the viewport changes
325
+ */
326
+ export interface VisibleChangeEvent<T extends Flicking = Flicking>
327
+ extends ComponentEvent<{}, (typeof EVENTS)["VISIBLE_CHANGE"], T> {
328
+ /** Panels that added from previous visible panels */
329
+ added: Panel[];
330
+ /** Panels that removed from previous visible panels */
331
+ removed: Panel[];
332
+ /** Current visible panels */
333
+ visiblePanels: Panel[];
334
+ }
335
+
336
+ /**
337
+ * Event that fires when camera reaches the maximum/minimum range
338
+ */
339
+ export interface ReachEdgeEvent<T extends Flicking = Flicking>
340
+ extends ComponentEvent<{}, (typeof EVENTS)["REACH_EDGE"], T> {
341
+ /** Direction indicates whether the camera's position is at the maximum range({@link DIRECTION | DIRECTION.NEXT}) or minimum range({@link DIRECTION | DIRECTION.PREV}) */
342
+ direction: ValueOf<typeof DIRECTION>;
343
+ }
344
+
345
+ /**
346
+ * Event that fires when a panel is added or removed
347
+ * @since 4.1.0
348
+ */
349
+ export interface PanelChangeEvent<T extends Flicking = Flicking>
350
+ extends ComponentEvent<{}, (typeof EVENTS)["PANEL_CHANGE"], T> {
351
+ /** An array of new panels added */
352
+ added: Panel[];
353
+ /** An array of panels removed */
354
+ removed: Panel[];
355
+ }
package/src/index.ts CHANGED
@@ -3,22 +3,20 @@
3
3
  * egjs projects are licensed under the MIT license
4
4
  */
5
5
  import Flicking from "./Flicking";
6
- import type { FlickingOptions, FlickingEvents } from "./Flicking";
7
- import type { CrossFlickingOptions } from "./CrossFlicking";
8
6
 
9
7
  export * from "./CrossFlicking";
10
-
11
- export * from "./core";
8
+ export * from "./CrossFlicking";
12
9
  export * from "./camera";
10
+ export * from "./cfc";
11
+ export * from "./constants/values";
13
12
  export * from "./control";
13
+ export * from "./core";
14
+ export * from "./error";
15
+ export * from "./event";
16
+ export * from "./Flicking";
17
+ export * from "./reactive";
14
18
  export * from "./renderer";
15
- export * from "./const/external";
16
- export * from "./cfc";
19
+ export * from "./types/external";
17
20
  export * from "./utils";
18
- export * from "./reactive";
19
-
20
- export * from "./type/event";
21
- export * from "./type/external";
22
- export type { FlickingOptions, FlickingEvents, CrossFlickingOptions };
23
21
 
24
22
  export default Flicking;
package/src/index.umd.ts CHANGED
@@ -2,13 +2,19 @@
2
2
  * Copyright (c) 2015 NAVER Corp.
3
3
  * egjs projects are licensed under the MIT license
4
4
  */
5
- import Flicking from "./Flicking";
5
+
6
6
  import * as CrossFlicking from "./CrossFlicking";
7
- import * as Core from "./core";
8
7
  import * as Camera from "./camera";
8
+ import * as Values from "./constants/values";
9
9
  import * as Control from "./control";
10
+ import * as Core from "./core";
11
+ import * as Events from "./event/names";
12
+ import Flicking from "./Flicking";
10
13
  import * as Renderer from "./renderer";
11
- import * as Constants from "./const/external";
14
+
15
+ // eslint-disable-next-line @typescript-eslint/naming-convention
16
+ const Constants = { ...Events, ...Values };
17
+
12
18
  import * as CFC from "./cfc";
13
19
  import * as FlickingReactiveAPI from "./reactive";
14
20
  import * as Utils from "./utils";
@@ -1,9 +1,4 @@
1
- import {
2
- adaptReactive,
3
- reactive,
4
- ReactiveObject,
5
- ReactiveSetupAdapter
6
- } from "@cfcs/core";
1
+ import { adaptReactive, ReactiveObject, ReactiveSetupAdapter, reactive } from "@cfcs/core";
7
2
 
8
3
  import Flicking from "../Flicking";
9
4
 
@@ -42,7 +37,7 @@ const getIndexProgress = (flicking: Flicking) => {
42
37
  const { min, max } = cam.range;
43
38
  const firstAnchorPoint = anchorPoints[0];
44
39
  const lastAnchorPoint = anchorPoints[length - 1];
45
- const distanceLastToFirst = (max - lastAnchorPoint.position) + (firstAnchorPoint.position - min);
40
+ const distanceLastToFirst = max - lastAnchorPoint.position + (firstAnchorPoint.position - min);
46
41
 
47
42
  anchorPoints.some((anchorPoint, index) => {
48
43
  const anchorPosition = anchorPoint.position;
@@ -60,7 +55,7 @@ const getIndexProgress = (flicking: Flicking) => {
60
55
  } else {
61
56
  indexProgress = index + (cameraPosition - anchorPosition) / anchorPoint.panel.size;
62
57
  }
63
- } else if (nextAnchorPoint && anchorPosition <= cameraPosition && cameraPosition <= nextAnchorPoint.position) {
58
+ } else if (nextAnchorPoint && anchorPosition <= cameraPosition && cameraPosition <= nextAnchorPoint.position) {
64
59
  indexProgress = index + (cameraPosition - anchorPosition) / (nextAnchorPoint.position - anchorPosition);
65
60
  } else {
66
61
  return false;
@@ -73,12 +68,9 @@ const getIndexProgress = (flicking: Flicking) => {
73
68
 
74
69
  /**
75
70
  * Reactive object type that combines state and methods for Flicking
71
+ * @remarks
76
72
  * This type provides reactive state properties and methods that automatically update
77
73
  * when the Flicking instance state changes.
78
- * @ko Flicking의 상태와 메서드를 결합한 반응형 객체 타입
79
- * 이 타입은 Flicking 인스턴스의 상태가 변경될 때 자동으로 업데이트되는
80
- * 반응형 상태 속성들과 메서드들을 제공합니다.
81
- * @typedef
82
74
  * @see {@link https://naver.github.io/egjs-flicking/Demos#reactive-api-demo}
83
75
  * @example
84
76
  * ```jsx
@@ -92,74 +84,49 @@ export type FlickingReactiveObject = ReactiveObject<FlickingReactiveState & Flic
92
84
 
93
85
  /**
94
86
  * Reactive state properties for Flicking
95
- * @ko Flicking의 반응형 상태 속성들
96
- * @typedef
97
87
  */
98
88
  export interface FlickingReactiveState {
99
- /**
100
- * Whether Flicking has reached the first panel<ko>첫 번째 패널에 도달했는지 여부</ko>
101
- */
89
+ /** Whether Flicking has reached the first panel */
102
90
  isReachStart: boolean;
103
- /**
104
- * Whether Flicking has reached the last panel<ko>마지막 패널에 도달했는지 여부</ko>
105
- */
91
+ /** Whether Flicking has reached the last panel */
106
92
  isReachEnd: boolean;
107
- /**
108
- * Total number of panels<ko>전체 패널 개수</ko>
109
- */
93
+ /** Total number of panels */
110
94
  totalPanelCount: number;
111
- /**
112
- * Current active panel index<ko>현재 활성화된 패널의 인덱스</ko>
113
- */
95
+ /** Current active panel index */
114
96
  currentPanelIndex: number;
115
- /**
116
- * Overall scroll progress percentage (0-100)<ko>전체 스크롤 진행률 (0-100)</ko>
117
- */
97
+ /** Overall scroll progress percentage (0-100) */
118
98
  progress: number;
119
- /**
120
- * Panel progress with decimal values<ko>소수점을 포함한 패널 진행률</ko>
121
- */
99
+ /** Panel progress with decimal values */
122
100
  indexProgress: number;
123
101
  }
124
102
 
125
103
  /**
126
104
  * Reactive methods for Flicking
127
- * @ko Flicking의 반응형 메서드들
128
- * @typedef
129
105
  */
130
106
  export interface FlickingReactiveMethod {
131
107
  /**
132
- * Move to a specific panel index<ko>특정 패널 인덱스로 이동</ko>
133
- * @param i - Target panel index<ko>목표 패널 인덱스</ko>
134
- * @returns Promise that resolves when movement is complete<ko>이동이 완료되면 resolve되는 Promise</ko>
108
+ * Move to a specific panel index
109
+ * @param i - Target panel index
110
+ * @returns Promise that resolves when movement is complete
135
111
  */
136
112
  moveTo: (i: number) => Promise<void>;
137
113
  }
138
114
 
139
115
  /**
140
116
  * Data required for reactive API setup
141
- * @ko 반응형 API 설정에 필요한 데이터
142
- * @typedef
143
117
  */
144
118
  export interface FlickingReactiveData {
145
- /**
146
- * Flicking instance to connect<ko>연결할 Flicking 인스턴스</ko>
147
- */
119
+ /** Flicking instance to connect */
148
120
  flicking?: Flicking;
149
- /**
150
- * Flicking options used for initialization<ko>초기화에 사용되는 Flicking 옵션</ko>
151
- */
121
+ /** Flicking options used for initialization */
152
122
  options?: FlickingReactiveAPIOptions;
153
123
  }
154
124
 
155
125
  /**
156
126
  * Options for Flicking reactive API that help optimize initial rendering in SSR scenarios
127
+ * @remarks
157
128
  * These options allow you to set initial state values before the Flicking instance is fully initialized,
158
129
  * preventing unnecessary re-renders when the actual Flicking state is applied.
159
- * @ko SSR 상황 등에서 초기 렌더링을 최적화할 수 있게 하는 Flicking 반응형 API 옵션
160
- * 이 옵션들을 통해 Flicking 인스턴스가 완전히 초기화되기 전에 초기 상태 값을 설정할 수 있어,
161
- * 실제 Flicking 상태가 적용될 때 불필요한 리렌더링을 방지할 수 있습니다.
162
- * @typedef
163
130
  * @example
164
131
  * ```js
165
132
  * const options = {
@@ -172,40 +139,35 @@ export interface FlickingReactiveData {
172
139
  export interface FlickingReactiveAPIOptions {
173
140
  /**
174
141
  * Initial panel index to start with. This sets the currentPanelIndex and indexProgress initial values.
142
+ * @remarks
175
143
  * Also affects isReachStart and isReachEnd initial value setting.
176
- * @ko 시작할 초기 패널 인덱스. currentPanelIndex와 indexProgress의 초기값을 설정합니다.
177
- * 또한 isReachStart, isReachEnd 초기값 계산에도 영향을 줍니다.
178
- * @default 0
144
+ * @defaultValue 0
179
145
  */
180
146
  defaultIndex?: number;
181
147
  /**
182
148
  * Total number of panels in the Flicking instance. This sets the totalPanelCount initial value
183
- * and helps prevent layout shifts during SSR hydration.
184
- * @ko Flicking 인스턴스의 전체 패널 개수. totalPanelCount의 초기값을 설정하며
185
- * SSR 하이드레이션 과정에서 레이아웃 시프트를 방지하는 데 도움이 됩니다.
186
- * @default 0
149
+ * @remarks
150
+ * Helps prevent layout shifts during SSR hydration.
151
+ * @defaultValue 0
187
152
  */
188
153
  totalPanelCount?: number;
189
154
  }
190
155
 
191
-
192
156
  /**
193
157
  * Internal reactive API adapter for Flicking that manages state and event listeners
158
+ * @remarks
194
159
  * This adapter is used internally by framework-specific packages (react-flicking, vue-flicking, etc.)
195
160
  * to provide reactive API support. Users rarely need to use this directly.
196
- * @ko Flicking의 상태와 이벤트 리스너를 관리하는 내부 반응형 API 어댑터
197
- * 어댑터는 react-flicking, vue-flicking 등의 프레임워크별 패키지에서 내부적으로 사용되어
198
- * 반응형 API 지원을 제공합니다. 사용자가 직접 사용할 일은 거의 없습니다.
199
- * @param onInit - Callback when reactive object is initialized<ko>반응형 객체가 초기화될 때 호출되는 콜백</ko>
200
- * @param onDestroy - Callback when reactive object is destroyed<ko>반응형 객체가 파괴될 때 호출되는 콜백</ko>
201
- * @param setMethods - Function to set available methods<ko>사용 가능한 메서드를 설정하는 함수</ko>
202
- * @returns Reactive object with Flicking state and methods<ko>Flicking 상태와 메서드를 포함한 반응형 객체</ko>
161
+ * @param onInit - Callback when reactive object is initialized
162
+ * @param onDestroy - Callback when reactive object is destroyed
163
+ * @param setMethods - Function to set available methods
164
+ * @returns Reactive object with Flicking state and methods
203
165
  */
204
166
  const flickingReactiveAPIAdapter: ReactiveSetupAdapter<
205
- FlickingReactiveObject,
206
- FlickingReactiveState,
207
- "moveTo",
208
- FlickingReactiveData
167
+ FlickingReactiveObject,
168
+ FlickingReactiveState,
169
+ "moveTo",
170
+ FlickingReactiveData
209
171
  > = ({ onInit, onDestroy, setMethods, getProps }) => {
210
172
  let flicking: Flicking | undefined;
211
173
 
@@ -227,7 +189,8 @@ FlickingReactiveData
227
189
  // 이렇게 미리 옵션을 통해서 예측할 수 있는 부분들은 맞춰둔다.
228
190
  const reactiveObj: FlickingReactiveObject = reactive({
229
191
  isReachStart: options?.defaultIndex ? options?.defaultIndex === 0 : true,
230
- isReachEnd: (options?.totalPanelCount && options?.defaultIndex) ? (options.defaultIndex === options.totalPanelCount - 1) : false,
192
+ isReachEnd:
193
+ options?.totalPanelCount && options?.defaultIndex ? options.defaultIndex === options.totalPanelCount - 1 : false,
231
194
  totalPanelCount: options?.totalPanelCount ?? 0,
232
195
  currentPanelIndex: options?.defaultIndex ?? 0,
233
196
  progress: 0,
@@ -287,10 +250,9 @@ FlickingReactiveData
287
250
 
288
251
  /**
289
252
  * Connect Flicking instance to reactive API
290
- * @ko Flicking 인스턴스를 반응형 API에 연결합니다
291
- * @param {Flicking} flicking - Flicking instance to connect<ko>연결할 Flicking 인스턴스</ko>
292
- * @param {FlickingReactiveAPIOptions} [options] - Flicking options<ko>Flicking 옵션</ko>
293
- * @returns {FlickingReactiveObject} Reactive object with Flicking state and methods<ko>Flicking 상태와 메서드를 포함한 반응형 객체</ko>
253
+ * @param flicking - Flicking instance to connect
254
+ * @param options - Flicking options
255
+ * @returns Reactive object with Flicking state and methods
294
256
  * @example
295
257
  * ```js
296
258
  * import Flicking, { connectFlickingReactiveAPI } from "@egjs/flicking";
@@ -315,7 +277,10 @@ FlickingReactiveData
315
277
  * reactiveObj.moveTo(2); // Move to third panel
316
278
  * ```
317
279
  */
318
- const connectFlickingReactiveAPI = (flicking: Flicking, options?: FlickingReactiveAPIOptions) => {
280
+ const connectFlickingReactiveAPI = (
281
+ flicking: Flicking,
282
+ options?: FlickingReactiveAPIOptions
283
+ ): FlickingReactiveObject => {
319
284
  const obj = adaptReactive(flickingReactiveAPIAdapter, () => ({ flicking, options }));
320
285
  obj.mounted();
321
286
  const instance = obj.instance();