@egjs/flicking 4.15.0 → 4.16.0-beta.1

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
@@ -4,19 +4,32 @@
4
4
  */
5
5
  import { OnRelease } from "@egjs/axes";
6
6
  import { ComponentEvent } from "@egjs/component";
7
-
8
- import Flicking from "../Flicking";
9
- import FlickingError from "../core/FlickingError";
10
- import Panel from "../core/panel/Panel";
7
+ import { DIRECTION } from "../constants/values";
11
8
  import AxesController from "../control/AxesController";
12
- import { DIRECTION, EVENTS } from "../const/external";
13
- import * as ERROR from "../const/error";
9
+ import Panel from "../core/panel/Panel";
10
+ import * as ERROR from "../error/codes";
11
+ import FlickingError from "../error/FlickingError";
12
+ import { EVENTS } from "../event/names";
13
+ import Flicking from "../Flicking";
14
+ import { ValueOf } from "../types/internal";
14
15
  import { getDirection, getFlickingAttached } from "../utils";
15
- import { ValueOf } from "../type/internal";
16
+
17
+ /**
18
+ * Parameters for {@link Control.moveToPanel}
19
+ * @public
20
+ */
21
+ export interface MoveToPanelParams {
22
+ /** Duration of the animation (unit: ms) */
23
+ duration: number;
24
+ /** Direction to move, only available in the {@link Flicking.circular | circular} mode */
25
+ direction?: ValueOf<typeof DIRECTION>;
26
+ /** {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-release | release} event of {@link https://naver.github.io/egjs-axes/ | Axes} */
27
+ axesEvent?: OnRelease;
28
+ }
16
29
 
17
30
  /**
18
31
  * A component that manages inputs and animation of Flicking
19
- * @ko Flicking의 입력 장치 & 애니메이션을 담당하는 컴포넌트
32
+ * @public
20
33
  */
21
34
  abstract class Control {
22
35
  // Internal States
@@ -26,43 +39,42 @@ abstract class Control {
26
39
  protected _nextPanel: Panel | null;
27
40
 
28
41
  /**
29
- * A controller that handles the {@link https://naver.github.io/egjs-axes/ @egjs/axes} events
30
- * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 이벤트를 처리하는 컨트롤러 컴포넌트
31
- * @type {AxesController}
42
+ * A controller that handles the {@link https://naver.github.io/egjs-axes/ | @egjs/axes} events
32
43
  * @readonly
33
44
  */
34
- public get controller() { return this._controller; }
45
+ public get controller(): AxesController {
46
+ return this._controller;
47
+ }
35
48
  /**
36
- * Index number of the {@link Flicking#currentPanel currentPanel}
37
- * @ko {@link Flicking#currentPanel currentPanel}의 인덱스 번호
38
- * @type {number}
39
- * @default 0
49
+ * Index number of the {@link Flicking.currentPanel | currentPanel}
50
+ * @defaultValue 0
40
51
  * @readonly
41
52
  */
42
- public get activeIndex() { return this._activePanel?.index ?? -1; }
53
+ public get activeIndex(): number {
54
+ return this._activePanel?.index ?? -1;
55
+ }
43
56
  /**
44
57
  * An active panel
45
- * @ko 현재 선택된 패널
46
- * @type {Panel | null}
47
58
  * @readonly
48
59
  */
49
- public get activePanel() { return this._activePanel; }
60
+ public get activePanel(): Panel | null {
61
+ return this._activePanel;
62
+ }
50
63
  /**
51
64
  * Whether Flicking's animating
52
- * @ko 현재 애니메이션 동작 여부
53
- * @type {boolean}
54
65
  * @readonly
55
66
  */
56
- public get animating() { return this._controller.state.animating; }
67
+ public get animating(): boolean {
68
+ return this._controller.state.animating;
69
+ }
57
70
  /**
58
71
  * Whether user is clicking or touching
59
- * @ko 현재 사용자가 클릭/터치중인지 여부
60
- * @type {boolean}
61
72
  * @readonly
62
73
  */
63
- public get holding() { return this._controller.state.holding; }
74
+ public get holding(): boolean {
75
+ return this._controller.state.holding;
76
+ }
64
77
 
65
- /** */
66
78
  public constructor() {
67
79
  this._flicking = null;
68
80
  this._controller = new AxesController();
@@ -71,53 +83,21 @@ abstract class Control {
71
83
 
72
84
  /**
73
85
  * Move {@link Camera} to the given position
74
- * @ko {@link Camera}를 주어진 좌표로 이동합니다
75
- * @method
76
- * @abstract
77
- * @memberof Control
78
- * @instance
79
- * @name moveToPosition
80
- * @param {number} position The target position to move<ko>이동할 좌표</ko>
81
- * @param {number} duration Duration of the panel movement animation (unit: ms).<ko>패널 이동 애니메이션 진행 시간 (단위: ms)</ko>
82
- * @param {object} [axesEvent] {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event of {@link https://naver.github.io/egjs-axes/ Axes}
83
- * <ko>{@link https://naver.github.io/egjs-axes/ Axes}의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트</ko>
84
- * @fires Flicking#moveStart
85
- * @fires Flicking#move
86
- * @fires Flicking#moveEnd
87
- * @fires Flicking#willChange
88
- * @fires Flicking#changed
89
- * @fires Flicking#willRestore
90
- * @fires Flicking#restored
91
- * @fires Flicking#needPanel
92
- * @fires Flicking#visibleChange
93
- * @fires Flicking#reachEdge
94
- * @throws {FlickingError}
95
- * |code|condition|
96
- * |---|---|
97
- * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|When the given panel is already removed or not in the Camera's {@link Camera#range range}|
98
- * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
99
- * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
100
- * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the animation is interrupted by user input|
101
- * <ko>
102
- *
103
- * |code|condition|
104
- * |---|---|
105
- * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우|
106
- * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
107
- * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
108
- * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
109
- *
110
- * </ko>
111
- * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
86
+ * @param position - The target position to move
87
+ * @param duration - Duration of the panel movement animation (unit: ms)
88
+ * @param axesEvent - {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-release | release} event of {@link https://naver.github.io/egjs-axes/ | Axes}
89
+ * @fires {@link MovementEvents}
90
+ * @throws {@link MovementErrors}
91
+ * @returns A Promise which will be resolved after reaching the target position
112
92
  */
113
93
  public abstract moveToPosition(position: number, duration: number, axesEvent?: OnRelease): Promise<void>;
114
94
 
115
95
  /**
116
96
  * Initialize Control
117
- * @ko Control을 초기화합니다
118
- * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
119
- * @chainable
120
- * @return {this}
97
+ * @remarks
98
+ * This method is called automatically during {@link Flicking.init}. It initializes the internal controller.
99
+ * @param flicking - An instance of {@link Flicking}
100
+ * @returns The current instance for method chaining
121
101
  */
122
102
  public init(flicking: Flicking): this {
123
103
  this._flicking = flicking;
@@ -128,8 +108,8 @@ abstract class Control {
128
108
 
129
109
  /**
130
110
  * Destroy Control and return to initial state
131
- * @ko Control을 초기 상태로 되돌립니다
132
- * @return {void}
111
+ * @remarks
112
+ * This method destroys the internal controller and resets all internal values.
133
113
  */
134
114
  public destroy(): void {
135
115
  this._controller.destroy();
@@ -140,9 +120,9 @@ abstract class Control {
140
120
 
141
121
  /**
142
122
  * Enable input from the user (mouse/touch)
143
- * @ko 사용자의 입력(마우스/터치)를 활성화합니다
144
- * @chainable
145
- * @return {this}
123
+ * @remarks
124
+ * This is a shorthand for `Flicking.enableInput`.
125
+ * @returns The current instance for method chaining
146
126
  */
147
127
  public enable(): this {
148
128
  this._controller.enable();
@@ -152,9 +132,9 @@ abstract class Control {
152
132
 
153
133
  /**
154
134
  * Disable input from the user (mouse/touch)
155
- * @ko 사용자의 입력(마우스/터치)를 막습니다
156
- * @chainable
157
- * @return {this}
135
+ * @remarks
136
+ * This is a shorthand for `Flicking.disableInput`.
137
+ * @returns The current instance for method chaining
158
138
  */
159
139
  public disable(): this {
160
140
  this._controller.disable();
@@ -164,9 +144,9 @@ abstract class Control {
164
144
 
165
145
  /**
166
146
  * Releases ongoing user input (mouse/touch)
167
- * @ko 사용자의 현재 입력(마우스/터치)를 중단시킵니다
168
- * @chainable
169
- * @return {this}
147
+ * @remarks
148
+ * This method immediately releases the user's input, similar to the user lifting their finger.
149
+ * @returns The current instance for method chaining
170
150
  */
171
151
  public release(): this {
172
152
  this._controller.release();
@@ -176,15 +156,13 @@ abstract class Control {
176
156
 
177
157
  /**
178
158
  * Change the destination and duration of the animation currently playing
179
- * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
180
- * @param {Panel} panel The target panel to move<ko>이동할 패널</ko>
181
- * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
182
- * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
183
- * @chainable
184
- * @throws {FlickingError}
185
- * {@link ERROR_CODE POSITION_NOT_REACHABLE} When the given panel is already removed or not in the Camera's {@link Camera#range range}
186
- * <ko>{@link ERROR_CODE POSITION_NOT_REACHABLE} 주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우</ko>
187
- * @return {this}
159
+ * @remarks
160
+ * This method does nothing if no animation is currently playing.
161
+ * @param panel - The target panel to move
162
+ * @param duration - Duration of the animation (unit: ms)
163
+ * @param direction - Direction to move, only available in the {@link Flicking.circular | circular} mode
164
+ * @throws {@link AnimationUpdateErrors}
165
+ * @returns The current instance for method chaining
188
166
  */
189
167
  public updateAnimation(panel: Panel, duration?: number, direction?: ValueOf<typeof DIRECTION>): this {
190
168
  const state = this._controller.state;
@@ -198,9 +176,9 @@ abstract class Control {
198
176
 
199
177
  /**
200
178
  * Stops the animation currently playing
201
- * @ko 재생 중인 애니메이션을 중단시킵니다
202
- * @chainable
203
- * @return {this}
179
+ * @remarks
180
+ * This method does nothing if no animation is currently playing.
181
+ * @returns The current instance for method chaining
204
182
  */
205
183
  public stopAnimation(): this {
206
184
  const state = this._controller.state;
@@ -213,15 +191,13 @@ abstract class Control {
213
191
 
214
192
  /**
215
193
  * Update position after resizing
216
- * @ko resize 이후에 position을 업데이트합니다
217
- * @param {number} progressInPanel Previous camera's progress in active panel before resize<ko>Resize 이전 현재 선택된 패널 내에서의 카메라 progress 값</ko>
218
- * @throws {FlickingError}
219
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
220
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
221
- * @chainable
222
- * @return {Promise<void>}
194
+ * @remarks
195
+ * This method moves the camera to the active panel's position after a resize operation.
196
+ * @param progressInPanel - Previous camera's progress in active panel before resize
197
+ * @throws {@link InitializationErrors}
223
198
  */
224
- public updatePosition(progressInPanel: number): void { // eslint-disable-line @typescript-eslint/no-unused-vars
199
+ public updatePosition(progressInPanel: number): void {
200
+ // eslint-disable-line @typescript-eslint/no-unused-vars
225
201
  const flicking = getFlickingAttached(this._flicking);
226
202
  const camera = flicking.camera;
227
203
  const activePanel = this._activePanel;
@@ -232,10 +208,10 @@ abstract class Control {
232
208
  }
233
209
 
234
210
  /**
235
- * Update {@link Control#controller controller}'s state
236
- * @ko {@link Control#controller controller}의 내부 상태를 갱신합니다
237
- * @chainable
238
- * @return {this}
211
+ * Update {@link Control.controller | controller}'s state
212
+ * @remarks
213
+ * This method synchronizes the controller state with the current camera parameters.
214
+ * @returns The current instance for method chaining
239
215
  */
240
216
  public updateInput(): this {
241
217
  const flicking = getFlickingAttached(this._flicking);
@@ -247,10 +223,10 @@ abstract class Control {
247
223
  }
248
224
 
249
225
  /**
250
- * Reset {@link Control#activePanel activePanel} to `null`
251
- * @ko {@link Control#activePanel activePanel}을 `null`로 초기화합니다
252
- * @chainable
253
- * @return {this}
226
+ * Reset {@link Control.activePanel | activePanel} to `null`
227
+ * @remarks
228
+ * This method is called when the active panel is removed from the renderer.
229
+ * @returns The current instance for method chaining
254
230
  */
255
231
  public resetActive(): this {
256
232
  this._activePanel = null;
@@ -260,51 +236,16 @@ abstract class Control {
260
236
 
261
237
  /**
262
238
  * Move {@link Camera} to the given panel
263
- * @ko {@link Camera}를 해당 패널 위로 이동합니다
264
- * @param {Panel} panel The target panel to move<ko>이동할 패널</ko>
265
- * @param {object} options An options object<ko>옵션 오브젝트</ko>
266
- * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
267
- * @param {object} [axesEvent] {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event of {@link https://naver.github.io/egjs-axes/ Axes}
268
- * <ko>{@link https://naver.github.io/egjs-axes/ Axes}의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트</ko>
269
- * @param {DIRECTION} [direction=DIRECTION.NONE] Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
270
- * @fires Flicking#moveStart
271
- * @fires Flicking#move
272
- * @fires Flicking#moveEnd
273
- * @fires Flicking#willChange
274
- * @fires Flicking#changed
275
- * @fires Flicking#willRestore
276
- * @fires Flicking#restored
277
- * @fires Flicking#needPanel
278
- * @fires Flicking#visibleChange
279
- * @fires Flicking#reachEdge
280
- * @throws {FlickingError}
281
- * |code|condition|
282
- * |---|---|
283
- * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|When the given panel is already removed or not in the Camera's {@link Camera#range range}|
284
- * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
285
- * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
286
- * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the animation is interrupted by user input|
287
- * <ko>
288
- *
289
- * |code|condition|
290
- * |---|---|
291
- * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우|
292
- * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
293
- * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
294
- * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
295
- *
296
- * </ko>
297
- * @return {Promise<void>} A Promise which will be resolved after reaching the target panel<ko>해당 패널 도달시에 resolve되는 Promise</ko>
239
+ * @param panel - The target panel to move
240
+ * @param options - {@link MoveToPanelParams}
241
+ * @fires {@link MovementEvents}
242
+ * @throws {@link MovementErrors}
243
+ * @returns A Promise which will be resolved after reaching the target panel
298
244
  */
299
- public async moveToPanel(panel: Panel, {
300
- duration,
301
- direction = DIRECTION.NONE,
302
- axesEvent
303
- }: {
304
- duration: number;
305
- direction?: ValueOf<typeof DIRECTION>;
306
- axesEvent?: OnRelease;
307
- }) {
245
+ public async moveToPanel(
246
+ panel: Panel,
247
+ { duration, direction = DIRECTION.NONE, axesEvent }: MoveToPanelParams
248
+ ): Promise<void> {
308
249
  const position = this._getPosition(panel, direction);
309
250
  this._triggerIndexChangeEvent(panel, panel.position, axesEvent, direction);
310
251
 
@@ -313,6 +254,8 @@ abstract class Control {
313
254
 
314
255
  /**
315
256
  * @internal
257
+ * @privateRemarks
258
+ * Sets the active panel and triggers {@link ChangedEvent} or {@link RestoredEvent} based on whether the panel changed.
316
259
  */
317
260
  public setActive(newActivePanel: Panel, prevActivePanel: Panel | null, isTrusted: boolean) {
318
261
  const flicking = getFlickingAttached(this._flicking);
@@ -323,23 +266,29 @@ abstract class Control {
323
266
  flicking.camera.updateAdaptiveHeight();
324
267
 
325
268
  if (newActivePanel !== prevActivePanel) {
326
- flicking.trigger(new ComponentEvent(EVENTS.CHANGED, {
327
- index: newActivePanel.index,
328
- panel: newActivePanel,
329
- prevIndex: prevActivePanel?.index ?? -1,
330
- prevPanel: prevActivePanel,
331
- isTrusted,
332
- direction: prevActivePanel ? getDirection(prevActivePanel.position, newActivePanel.position) : DIRECTION.NONE
333
- }));
269
+ flicking.trigger(
270
+ new ComponentEvent(EVENTS.CHANGED, {
271
+ index: newActivePanel.index,
272
+ panel: newActivePanel,
273
+ prevIndex: prevActivePanel?.index ?? -1,
274
+ prevPanel: prevActivePanel,
275
+ isTrusted,
276
+ direction: prevActivePanel ? getDirection(prevActivePanel.position, newActivePanel.position) : DIRECTION.NONE
277
+ })
278
+ );
334
279
  } else {
335
- flicking.trigger(new ComponentEvent(EVENTS.RESTORED, {
336
- isTrusted
337
- }));
280
+ flicking.trigger(
281
+ new ComponentEvent(EVENTS.RESTORED, {
282
+ isTrusted
283
+ })
284
+ );
338
285
  }
339
286
  }
340
287
 
341
288
  /**
342
289
  * @internal
290
+ * @privateRemarks
291
+ * Copies internal state from another Control instance. Used when changing moveType option.
343
292
  */
344
293
  public copy(control: Control) {
345
294
  this._flicking = control._flicking;
@@ -347,7 +296,17 @@ abstract class Control {
347
296
  this._controller = control._controller;
348
297
  }
349
298
 
350
- protected _triggerIndexChangeEvent(panel: Panel, position: number, axesEvent?: OnRelease, direction?: ValueOf<typeof DIRECTION>) {
299
+ /**
300
+ * @internal
301
+ * @privateRemarks
302
+ * Triggers {@link WillChangeEvent} or {@link WillRestoreEvent} based on whether the target panel differs from the active panel.
303
+ */
304
+ protected _triggerIndexChangeEvent(
305
+ panel: Panel,
306
+ position: number,
307
+ axesEvent?: OnRelease,
308
+ direction?: ValueOf<typeof DIRECTION>
309
+ ) {
351
310
  const flicking = getFlickingAttached(this._flicking);
352
311
  const triggeringEvent = panel !== this._activePanel ? EVENTS.WILL_CHANGE : EVENTS.WILL_RESTORE;
353
312
  const camera = flicking.camera;
@@ -368,6 +327,11 @@ abstract class Control {
368
327
  }
369
328
  }
370
329
 
330
+ /**
331
+ * @internal
332
+ * @privateRemarks
333
+ * Animates the camera to the target position and handles animation completion or interruption.
334
+ */
371
335
  protected async _animateToPosition({
372
336
  position,
373
337
  duration,
@@ -380,7 +344,6 @@ abstract class Control {
380
344
  axesEvent?: OnRelease;
381
345
  }) {
382
346
  const flicking = getFlickingAttached(this._flicking);
383
-
384
347
  // 거리(1px 미만)가 매우 짧은 경우 duration이 늘어지는걸 방지하기 위해 0으로 바꿔 즉시 변경
385
348
  let nextDuration = duration;
386
349
 
@@ -395,17 +358,24 @@ abstract class Control {
395
358
  if (nextDuration <= 0) {
396
359
  return animate();
397
360
  } else {
398
- return animate().then(async () => {
399
- if (flicking.initialized) {
400
- await flicking.renderer.render();
401
- }
402
- }).catch(err => {
403
- if (axesEvent && err instanceof FlickingError && err.code === ERROR.CODE.ANIMATION_INTERRUPTED) return;
404
- throw err;
405
- });
361
+ return animate()
362
+ .then(async () => {
363
+ if (flicking.initialized) {
364
+ await flicking.renderer.render();
365
+ }
366
+ })
367
+ .catch(err => {
368
+ if (axesEvent && err instanceof FlickingError && err.code === ERROR.CODE.ANIMATION_INTERRUPTED) return;
369
+ throw err;
370
+ });
406
371
  }
407
372
  }
408
373
 
374
+ /**
375
+ * @internal
376
+ * @privateRemarks
377
+ * Calculates the target position for a panel, considering circular mode and direction constraints.
378
+ */
409
379
  private _getPosition(panel: Panel, direction: ValueOf<typeof DIRECTION> = DIRECTION.NONE) {
410
380
  const flicking = getFlickingAttached(this._flicking);
411
381
  const camera = flicking.camera;
@@ -424,14 +394,11 @@ abstract class Control {
424
394
  // Circular mode is enabled, find nearest distance to panel
425
395
  const camPos = this._controller.position; // Actual position of the Axes
426
396
  const camRangeDiff = camera.rangeDiff;
427
- const possiblePositions = [position, position + camRangeDiff, position - camRangeDiff]
428
- .filter(pos => {
429
- if (direction === DIRECTION.NONE) return true;
397
+ const possiblePositions = [position, position + camRangeDiff, position - camRangeDiff].filter(pos => {
398
+ if (direction === DIRECTION.NONE) return true;
430
399
 
431
- return direction === DIRECTION.PREV
432
- ? pos <= camPos
433
- : pos >= camPos;
434
- });
400
+ return direction === DIRECTION.PREV ? pos <= camPos : pos >= camPos;
401
+ });
435
402
 
436
403
  position = possiblePositions.reduce((nearestPosition, pos) => {
437
404
  if (Math.abs(camPos - pos) < Math.abs(camPos - nearestPosition)) {
@@ -3,59 +3,53 @@
3
3
  * egjs projects are licensed under the MIT license
4
4
  */
5
5
  import { OnRelease } from "@egjs/axes";
6
-
7
- import FlickingError from "../core/FlickingError";
8
- import * as ERROR from "../const/error";
6
+ import * as ERROR from "../error/codes";
7
+ import FlickingError from "../error/FlickingError";
9
8
  import { getFlickingAttached } from "../utils";
10
9
 
11
10
  import Control from "./Control";
12
11
 
13
12
  /**
14
- * An options for the {@link FreeControl}
15
- * @ko {@link FreeControl} 생성시 사용되는 옵션
16
- * @interface
17
- * @property {boolean} stopAtEdge Make scroll animation to stop at the start/end of the scroll area, not going out the bounce area
18
- * <ko>스크롤 애니메이션을 스크롤 영역의 시작과 끝부분에서 멈추도록 하여, 바운스 영역을 넘어가지 않도록 합니다</ko>
13
+ * Options for the {@link FreeControl}
19
14
  */
20
15
  export interface FreeControlOptions {
16
+ /** Make scroll animation to stop at the start/end of the scroll area, not going out the bounce area */
21
17
  stopAtEdge: boolean;
22
18
  }
23
19
 
24
20
  /**
25
21
  * A {@link Control} that can be scrolled freely without alignment
26
- * @ko 패널이 정해진 지점에 정렬되지 않고, 자유롭게 스크롤할 수 있는 이동 방식을 사용하는 {@link Control}
22
+ * @public
27
23
  */
28
24
  class FreeControl extends Control {
29
25
  private _stopAtEdge: FreeControlOptions["stopAtEdge"];
30
26
 
31
27
  /**
32
28
  * Make scroll animation to stop at the start/end of the scroll area, not going out the bounce area
33
- * @ko 스크롤 애니메이션을 스크롤 영역의 시작과 끝부분에서 멈추도록 하여, 바운스 영역을 넘어가지 않도록 합니다
34
- * @type {boolean}
35
- * @default true
29
+ * @defaultValue true
36
30
  */
37
- public get stopAtEdge() { return this._stopAtEdge; }
31
+ public get stopAtEdge(): boolean {
32
+ return this._stopAtEdge;
33
+ }
38
34
 
39
- public set stopAtEdge(val: FreeControlOptions["stopAtEdge"]) { this._stopAtEdge = val; }
35
+ public set stopAtEdge(val: FreeControlOptions["stopAtEdge"]) {
36
+ this._stopAtEdge = val;
37
+ }
40
38
 
41
- /** */
42
- public constructor({
43
- stopAtEdge = true
44
- }: Partial<FreeControlOptions> = {}) {
39
+ public constructor(options: Partial<FreeControlOptions> = {}) {
45
40
  super();
46
41
 
42
+ const { stopAtEdge = true } = options;
43
+
47
44
  this._stopAtEdge = stopAtEdge;
48
45
  }
49
46
 
50
47
  /**
51
48
  * Update position after resizing
52
- * @ko resize 이후에 position을 업데이트합니다
53
- * @param {number} progressInPanel Previous camera's progress in active panel before resize<ko>Resize 이전 현재 선택된 패널 내에서의 카메라 progress 값</ko>
54
- * @throws {FlickingError}
55
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
56
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
57
- * @chainable
58
- * @return {Promise<void>}
49
+ * @remarks
50
+ * Unlike the base Control, FreeControl preserves the progress within the panel instead of snapping to the panel position.
51
+ * @param progressInPanel - Previous camera's progress in active panel before resize
52
+ * @throws {@link InitializationErrors}
59
53
  */
60
54
  public updatePosition(progressInPanel: number): void {
61
55
  const flicking = getFlickingAttached(this._flicking);
@@ -72,39 +66,14 @@ class FreeControl extends Control {
72
66
 
73
67
  /**
74
68
  * Move {@link Camera} to the given position
75
- * @ko {@link Camera}를 주어진 좌표로 이동합니다
76
- * @param {number} position The target position to move<ko>이동할 좌표</ko>
77
- * @param {number} duration Duration of the panel movement animation (unit: ms).<ko>패널 이동 애니메이션 진행 시간 (단위: ms)</ko>
78
- * @param {object} [axesEvent] {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event of {@link https://naver.github.io/egjs-axes/ Axes}
79
- * <ko>{@link https://naver.github.io/egjs-axes/ Axes} {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트</ko>
80
- * @fires Flicking#moveStart
81
- * @fires Flicking#move
82
- * @fires Flicking#moveEnd
83
- * @fires Flicking#willChange
84
- * @fires Flicking#changed
85
- * @fires Flicking#willRestore
86
- * @fires Flicking#restored
87
- * @fires Flicking#needPanel
88
- * @fires Flicking#visibleChange
89
- * @fires Flicking#reachEdge
90
- * @throws {FlickingError}
91
- * |code|condition|
92
- * |---|---|
93
- * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|When the given panel is already removed or not in the Camera's {@link Camera#range range}|
94
- * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
95
- * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
96
- * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the animation is interrupted by user input|
97
- * <ko>
98
- *
99
- * |code|condition|
100
- * |---|---|
101
- * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우|
102
- * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
103
- * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
104
- * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
105
- *
106
- * </ko>
107
- * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
69
+ * @remarks
70
+ * Unlike SnapControl, FreeControl moves to the exact position without snapping to panel boundaries.
71
+ * @param position - The target position to move
72
+ * @param duration - Duration of the panel movement animation (unit: ms)
73
+ * @param axesEvent - {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-release | release} event of {@link https://naver.github.io/egjs-axes/ | Axes}
74
+ * @fires {@link MovementEvents}
75
+ * @throws {@link MovementErrors}
76
+ * @returns A Promise which will be resolved after reaching the target position
108
77
  */
109
78
  public moveToPosition(position: number, duration: number, axesEvent?: OnRelease) {
110
79
  const flicking = getFlickingAttached(this._flicking);
@@ -115,7 +84,9 @@ class FreeControl extends Control {
115
84
  const anchorAtPosition = camera.findAnchorIncludePosition(targetPos);
116
85
 
117
86
  if (!anchorAtPosition) {
118
- return Promise.reject(new FlickingError(ERROR.MESSAGE.POSITION_NOT_REACHABLE(position), ERROR.CODE.POSITION_NOT_REACHABLE));
87
+ return Promise.reject(
88
+ new FlickingError(ERROR.MESSAGE.POSITION_NOT_REACHABLE(position), ERROR.CODE.POSITION_NOT_REACHABLE)
89
+ );
119
90
  }
120
91
 
121
92
  const targetPanel = anchorAtPosition.panel;
@@ -125,7 +96,12 @@ class FreeControl extends Control {
125
96
  this._triggerIndexChangeEvent(targetPanel, position, axesEvent);
126
97
  }
127
98
 
128
- return this._animateToPosition({ position: this._stopAtEdge ? targetPos : position, duration, newActivePanel: targetPanel, axesEvent });
99
+ return this._animateToPosition({
100
+ position: this._stopAtEdge ? targetPos : position,
101
+ duration,
102
+ newActivePanel: targetPanel,
103
+ axesEvent
104
+ });
129
105
  }
130
106
  }
131
107