@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,24 +4,55 @@
4
4
  */
5
5
  import { ComponentEvent } from "@egjs/component";
6
6
  import ImReady from "@egjs/imready";
7
-
8
- import Flicking, { FlickingOptions } from "../Flicking";
7
+ import { ALIGN } from "../constants/values";
9
8
  import Panel, { PanelOptions } from "../core/panel/Panel";
10
- import FlickingError from "../core/FlickingError";
11
- import { ALIGN, EVENTS } from "../const/external";
12
- import * as ERROR from "../const/error";
9
+ import * as ERROR from "../error/codes";
10
+ import FlickingError from "../error/FlickingError";
11
+ import { EVENTS } from "../event/names";
12
+ import Flicking, { FlickingOptions } from "../Flicking";
13
13
  import { getFlickingAttached, getMinusCompensatedIndex, includes, parsePanelAlign } from "../utils";
14
14
 
15
15
  import RenderingStrategy from "./strategy/RenderingStrategy";
16
16
 
17
+ /**
18
+ * Options for creating a {@link Renderer}
19
+ */
17
20
  export interface RendererOptions {
21
+ /** An {@link Flicking.align | align} value that will be applied to all panels */
18
22
  align?: FlickingOptions["align"];
23
+ /** An instance of RenderingStrategy(internal module) */
19
24
  strategy: RenderingStrategy;
20
25
  }
21
26
 
27
+ /**
28
+ * Parameters for {@link Renderer.batchInsert}
29
+ * @public
30
+ */
31
+ export interface BatchInsertParams {
32
+ /** Index to insert new panels at */
33
+ index: number;
34
+ /** An array of element or framework component with element in it */
35
+ elements: any[];
36
+ /** Whether it contains actual DOM elements. If set to true, renderer will add them to the camera element */
37
+ hasDOMInElements: boolean;
38
+ }
39
+
40
+ /**
41
+ * Parameters for {@link Renderer.batchRemove}
42
+ * @public
43
+ */
44
+ export interface BatchRemoveParams {
45
+ /** Index of panel to remove */
46
+ index: number;
47
+ /** Number of panels to remove from index */
48
+ deleteCount: number;
49
+ /** Whether it contains actual DOM elements. If set to true, renderer will remove them from the camera element */
50
+ hasDOMInElements: boolean;
51
+ }
52
+
22
53
  /**
23
54
  * A component that manages {@link Panel} and its elements
24
- * @ko {@link Panel}과 그 엘리먼트들을 관리하는 컴포넌트
55
+ * @public
25
56
  */
26
57
  abstract class Renderer {
27
58
  // Internal States
@@ -36,57 +67,59 @@ abstract class Renderer {
36
67
  // Internal states Getter
37
68
  /**
38
69
  * Array of panels
39
- * @ko 전체 패널들의 배열
40
- * @type {Panel[]}
41
70
  * @readonly
42
71
  * @see Panel
43
72
  */
44
- public get panels() { return this._panels; }
73
+ public get panels(): Panel[] {
74
+ return this._panels;
75
+ }
45
76
  /**
46
77
  * A boolean value indicating whether rendering is in progress
47
- * @ko 현재 렌더링이 시작되어 끝나기 전까지의 상태인지의 여부
48
- * @type {boolean}
49
78
  * @readonly
50
79
  * @internal
51
80
  */
52
- public get rendering() { return this._rendering; }
81
+ public get rendering(): boolean {
82
+ return this._rendering;
83
+ }
53
84
  /**
54
85
  * Count of panels
55
- * @ko 전체 패널의 개수
56
- * @type {number}
57
86
  * @readonly
58
87
  */
59
- public get panelCount() { return this._panels.length; }
88
+ public get panelCount(): number {
89
+ return this._panels.length;
90
+ }
60
91
  /**
61
92
  * @internal
62
93
  */
63
- public get strategy() { return this._strategy; }
94
+ public get strategy(): RendererOptions["strategy"] {
95
+ return this._strategy;
96
+ }
64
97
 
65
98
  // Options Getter
66
99
  /**
67
- * A {@link Panel}'s {@link Panel#align align} value that applied to all panels
68
- * @ko {@link Panel}에 공통적으로 적용할 {@link Panel#align align} 값
69
- * @type {Constants.ALIGN | string | number}
100
+ * A {@link Panel}'s {@link Panel.align | align} value that applied to all panels
70
101
  */
71
- public get align() { return this._align; }
102
+ public get align(): NonNullable<RendererOptions["align"]> {
103
+ return this._align;
104
+ }
72
105
 
73
106
  // Options Setter
74
107
  public set align(val: NonNullable<RendererOptions["align"]>) {
75
108
  this._align = val;
76
109
 
77
110
  const panelAlign = parsePanelAlign(val);
78
- this._panels.forEach(panel => { panel.align = panelAlign; });
111
+ this._panels.forEach(panel => {
112
+ panel.align = panelAlign;
113
+ });
79
114
  }
80
115
 
81
116
  /**
82
- * @param {object} options An options object<ko>옵션 오브젝트</ko>
83
- * @param {Constants.ALIGN | string | number} [options.align="center"] An {@link Flicking#align align} value that will be applied to all panels<ko>전체 패널에 적용될 {@link Flicking#align align} 값</ko>
84
- * @param {object} [options.strategy] An instance of RenderingStrategy(internal module)<ko>RenderingStrategy의 인스턴스(내부 모듈)</ko>
117
+ * @param options - {@link RendererOptions}
85
118
  */
86
- public constructor({
87
- align = ALIGN.CENTER,
88
- strategy
89
- }: RendererOptions) {
119
+ public constructor(options: RendererOptions) {
120
+ // Destructure options with default values
121
+ const { align = ALIGN.CENTER, strategy } = options;
122
+
90
123
  this._flicking = null;
91
124
  this._panels = [];
92
125
  this._rendering = false;
@@ -98,26 +131,31 @@ abstract class Renderer {
98
131
 
99
132
  /**
100
133
  * Render panel elements inside the camera element
101
- * @ko 패널 엘리먼트들을 카메라 엘리먼트 내부에 렌더링합니다
102
- * @method
103
- * @abstract
104
- * @memberof Renderer
105
- * @instance
106
- * @name render
107
- * @chainable
108
- * @return {this}
134
+ * @remarks
135
+ * This method updates the DOM to reflect the current panel state.
136
+ * @returns A Promise that resolves when rendering is complete
109
137
  */
110
138
  public abstract render(): Promise<void>;
111
139
 
140
+ /**
141
+ * @internal
142
+ * @privateRemarks
143
+ * Collects panel elements from the camera element and creates Panel instances.
144
+ */
112
145
  protected abstract _collectPanels(): void;
146
+ /**
147
+ * @internal
148
+ * @privateRemarks
149
+ * Creates a Panel instance from an element with the given options.
150
+ */
113
151
  protected abstract _createPanel(el: any, options: Omit<PanelOptions, "elementProvider">): Panel;
114
152
 
115
153
  /**
116
154
  * Initialize Renderer
117
- * @ko Renderer를 초기화합니다
118
- * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
119
- * @chainable
120
- * @return {this}
155
+ * @remarks
156
+ * This method is called automatically during {@link Flicking.init}. It collects existing panel elements.
157
+ * @param flicking - An instance of {@link Flicking}
158
+ * @returns The current instance for method chaining
121
159
  */
122
160
  public init(flicking: Flicking): this {
123
161
  this._flicking = flicking;
@@ -128,8 +166,8 @@ abstract class Renderer {
128
166
 
129
167
  /**
130
168
  * Destroy Renderer and return to initial state
131
- * @ko Renderer를 초기 상태로 되돌립니다
132
- * @return {void}
169
+ * @remarks
170
+ * This method clears all panel references and resets the internal state.
133
171
  */
134
172
  public destroy(): void {
135
173
  this._flicking = null;
@@ -137,9 +175,11 @@ abstract class Renderer {
137
175
  }
138
176
 
139
177
  /**
140
- * Return the {@link Panel} at the given index. `null` if it doesn't exists.
141
- * @ko 주어진 인덱스에 해당하는 {@link Panel}을 반환합니다. 주어진 인덱스에 해당하는 패널이 존재하지 않을 경우 `null`을 반환합니다.
142
- * @return {Panel | null} Panel at the given index<ko>주어진 인덱스에 해당하는 패널</ko>
178
+ * Return the {@link Panel} at the given index. `null` if it doesn't exist.
179
+ * @remarks
180
+ * This is equivalent to accessing `Flicking.panels[index]`.
181
+ * @param index - Index of the panel to get
182
+ * @returns Panel at the given index
143
183
  * @see Panel
144
184
  */
145
185
  public getPanel(index: number): Panel | null {
@@ -154,10 +194,9 @@ abstract class Renderer {
154
194
 
155
195
  /**
156
196
  * Return Rendered Panels
157
- * @ko 렌더링이 된 패널을 반환합니다.
158
- * @return {Panel[]}
197
+ * @returns Rendered Panels
159
198
  */
160
- public getRenderedPanels() {
199
+ public getRenderedPanels(): Panel[] {
161
200
  const flicking = getFlickingAttached(this._flicking);
162
201
 
163
202
  return flicking.renderer.panels.filter(panel => panel.rendered);
@@ -165,9 +204,7 @@ abstract class Renderer {
165
204
 
166
205
  /**
167
206
  * Update all panel sizes
168
- * @ko 모든 패널의 크기를 업데이트합니다
169
- * @chainable
170
- * @return {this}
207
+ * @returns The current instance for method chaining
171
208
  */
172
209
  public updatePanelSize(): this {
173
210
  const flicking = getFlickingAttached(this._flicking);
@@ -189,20 +226,13 @@ abstract class Renderer {
189
226
 
190
227
  /**
191
228
  * Insert new panels at given index
192
- * This will increase index of panels after by the number of panels added
193
- * @ko 주어진 인덱스에 새로운 패널들을 추가합니다
194
- * 해당 인덱스보다 같거나 인덱스를 가진 기존 패널들은 추가한 패널의 개수만큼 인덱스가 증가합니다.
195
- * @param {Array<object>} items An array of items to insert<ko>추가할 아이템들의 배열</ko>
196
- * @param {number} [items.index] Index to insert new panels at<ko>새로 패널들을 추가할 인덱스</ko>
197
- * @param {any[]} [items.elements] An array of element or framework component with element in it<ko>엘리먼트의 배열 혹은 프레임워크에서 엘리먼트를 포함한 컴포넌트들의 배열</ko>
198
- * @param {boolean} [items.hasDOMInElements] Whether it contains actual DOM elements. If set to true, renderer will add them to the camera element<ko>내부에 실제 DOM 엘리먼트들을 포함하고 있는지 여부. true로 설정할 경우, 렌더러는 해당 엘리먼트들을 카메라 엘리먼트 내부에 추가합니다</ko>
199
- * @return {Panel[]} An array of prepended panels<ko>추가된 패널들의 배열</ko>
229
+ * @remarks
230
+ * This will increase index of panels after by the number of panels added.
231
+ * @param items - An array of {@link BatchInsertParams}
232
+ * @throws {@link DOMManipulationErrors}
233
+ * @returns An array of inserted panels
200
234
  */
201
- public batchInsert(...items: Array<{
202
- index: number;
203
- elements: any[];
204
- hasDOMInElements: boolean;
205
- }>): Panel[] {
235
+ public batchInsert(...items: BatchInsertParams[]): Panel[] {
206
236
  const allPanelsInserted = this.batchInsertDefer(...items);
207
237
 
208
238
  if (allPanelsInserted.length <= 0) return [];
@@ -213,15 +243,11 @@ abstract class Renderer {
213
243
  }
214
244
 
215
245
  /**
216
- * Defers update
217
- * camera position & others will be updated after calling updateAfterPanelChange
218
246
  * @internal
247
+ * @privateRemarks
248
+ * Defers update. Camera position & others will be updated after calling updateAfterPanelChange.
219
249
  */
220
- public batchInsertDefer(...items: Array<{
221
- index: number;
222
- elements: any[];
223
- hasDOMInElements: boolean;
224
- }>) {
250
+ public batchInsertDefer(...items: BatchInsertParams[]) {
225
251
  const panels = this._panels;
226
252
  const flicking = getFlickingAttached(this._flicking);
227
253
 
@@ -231,7 +257,9 @@ abstract class Renderer {
231
257
  const allPanelsInserted = items.reduce((addedPanels, item) => {
232
258
  const insertingIdx = getMinusCompensatedIndex(item.index, panels.length);
233
259
  const panelsPushed = panels.slice(insertingIdx);
234
- const panelsInserted = item.elements.map((el, idx) => this._createPanel(el, { index: insertingIdx + idx, align, flicking }));
260
+ const panelsInserted = item.elements.map((el, idx) =>
261
+ this._createPanel(el, { index: insertingIdx + idx, align, flicking })
262
+ );
235
263
 
236
264
  panels.splice(insertingIdx, 0, ...panelsInserted);
237
265
 
@@ -263,20 +291,13 @@ abstract class Renderer {
263
291
 
264
292
  /**
265
293
  * Remove the panel at the given index
266
- * This will decrease index of panels after by the number of panels removed
267
- * @ko 주어진 인덱스의 패널을 제거합니다
268
- * 해당 인덱스보다 인덱스를 가진 기존 패널들은 제거한 패널의 개수만큼 인덱스가 감소합니다
269
- * @param {Array<object>} items An array of items to remove<ko>제거할 아이템들의 배열</ko>
270
- * @param {number} [items.index] Index of panel to remove<ko>제거할 패널의 인덱스</ko>
271
- * @param {number} [items.deleteCount=1] Number of panels to remove from index<ko>`index` 이후로 제거할 패널의 개수</ko>
272
- * @param {boolean} [items.hasDOMInElements=1] Whether it contains actual DOM elements. If set to true, renderer will remove them from the camera element<ko>내부에 실제 DOM 엘리먼트들을 포함하고 있는지 여부. true로 설정할 경우, 렌더러는 해당 엘리먼트들을 카메라 엘리먼트 내부에서 제거합니다</ko>
273
- * @return An array of removed panels<ko>제거된 패널들의 배열</ko>
294
+ * @remarks
295
+ * This will decrease index of panels after by the number of panels removed.
296
+ * @param items - An array of {@link BatchRemoveParams}
297
+ * @throws {@link DOMManipulationErrors}
298
+ * @returns An array of removed panels
274
299
  */
275
- public batchRemove(...items: Array<{
276
- index: number;
277
- deleteCount: number;
278
- hasDOMInElements: boolean;
279
- }>): Panel[] {
300
+ public batchRemove(...items: BatchRemoveParams[]): Panel[] {
280
301
  const allPanelsRemoved = this.batchRemoveDefer(...items);
281
302
 
282
303
  if (allPanelsRemoved.length <= 0) return [];
@@ -287,15 +308,11 @@ abstract class Renderer {
287
308
  }
288
309
 
289
310
  /**
290
- * Defers update
291
- * camera position & others will be updated after calling updateAfterPanelChange
292
311
  * @internal
312
+ * @privateRemarks
313
+ * Defers update. Camera position & others will be updated after calling updateAfterPanelChange.
293
314
  */
294
- public batchRemoveDefer(...items: Array<{
295
- index: number;
296
- deleteCount: number;
297
- hasDOMInElements: boolean;
298
- }>) {
315
+ public batchRemoveDefer(...items: BatchRemoveParams[]) {
299
316
  const panels = this._panels;
300
317
  const flicking = getFlickingAttached(this._flicking);
301
318
 
@@ -336,6 +353,8 @@ abstract class Renderer {
336
353
 
337
354
  /**
338
355
  * @internal
356
+ * @privateRemarks
357
+ * Updates camera, control, and triggers {@link PanelChangeEvent} after panels are added or removed.
339
358
  */
340
359
  public updateAfterPanelChange(panelsAdded: Panel[], panelsRemoved: Panel[]) {
341
360
  const flicking = getFlickingAttached(this._flicking);
@@ -347,12 +366,12 @@ abstract class Renderer {
347
366
  this._updateCameraAndControl();
348
367
 
349
368
  if (flicking.autoResize && flicking.useResizeObserver) {
350
- panelsAdded.forEach((panel) => {
369
+ panelsAdded.forEach(panel => {
351
370
  if (panel.element) {
352
371
  flicking.autoResizer.observe(panel.element);
353
372
  }
354
373
  });
355
- panelsRemoved.forEach((panel) => {
374
+ panelsRemoved.forEach(panel => {
356
375
  if (panel.element) {
357
376
  flicking.autoResizer.unobserve(panel.element);
358
377
  }
@@ -372,34 +391,39 @@ abstract class Renderer {
372
391
  targetIndex = panels.length - 1;
373
392
  }
374
393
 
375
- void control.moveToPanel(panels[targetIndex], {
376
- duration: 0
377
- }).catch(() => void 0);
394
+ void control
395
+ .moveToPanel(panels[targetIndex], {
396
+ duration: 0
397
+ })
398
+ .catch(() => void 0);
378
399
  }
379
400
  } else {
380
- void control.moveToPanel(activePanel, {
381
- duration: 0
382
- }).catch(() => void 0);
401
+ void control
402
+ .moveToPanel(activePanel, {
403
+ duration: 0
404
+ })
405
+ .catch(() => void 0);
383
406
  }
384
407
  }
385
408
 
386
409
  flicking.camera.updateOffset();
387
410
 
388
411
  if (panelsAdded.length > 0 || panelsRemoved.length > 0) {
389
- flicking.trigger(new ComponentEvent(EVENTS.PANEL_CHANGE, {
390
- added: panelsAdded,
391
- removed: panelsRemoved
392
- }));
393
-
394
- this.checkPanelContentsReady([
395
- ...panelsAdded,
396
- ...panelsRemoved
397
- ]);
412
+ flicking.trigger(
413
+ new ComponentEvent(EVENTS.PANEL_CHANGE, {
414
+ added: panelsAdded,
415
+ removed: panelsRemoved
416
+ })
417
+ );
418
+
419
+ this.checkPanelContentsReady([...panelsAdded, ...panelsRemoved]);
398
420
  }
399
421
  }
400
422
 
401
423
  /**
402
424
  * @internal
425
+ * @privateRemarks
426
+ * Checks if panel contents (images/videos) are ready and triggers resize when loaded.
403
427
  */
404
428
  public checkPanelContentsReady(checkingPanels: Panel[]) {
405
429
  const flicking = getFlickingAttached(this._flicking);
@@ -429,9 +453,7 @@ abstract class Renderer {
429
453
  const panel = checkingPanels[e.index];
430
454
  const camera = flicking.camera;
431
455
  const control = flicking.control;
432
- const prevProgressInPanel = control.activePanel
433
- ? camera.getProgressInPanel(control.activePanel)
434
- : 0;
456
+ const prevProgressInPanel = control.activePanel ? camera.getProgressInPanel(control.activePanel) : 0;
435
457
 
436
458
  panel.loading = false;
437
459
  panel.resize();
@@ -471,6 +493,11 @@ abstract class Renderer {
471
493
  contentsReadyChecker.check(checkingPanels.map(panel => panel.element));
472
494
  }
473
495
 
496
+ /**
497
+ * @internal
498
+ * @privateRemarks
499
+ * Updates camera range, anchors, and control input after panel changes.
500
+ */
474
501
  protected _updateCameraAndControl() {
475
502
  const flicking = getFlickingAttached(this._flicking);
476
503
  const { camera, control } = flicking;
@@ -482,6 +509,11 @@ abstract class Renderer {
482
509
  control.updateInput();
483
510
  }
484
511
 
512
+ /**
513
+ * @internal
514
+ * @privateRemarks
515
+ * Marks only visible panels for rendering when {@link FlickingOptions.renderOnlyVisible | renderOnlyVisible} is enabled.
516
+ */
485
517
  protected _showOnlyVisiblePanels(flicking: Flicking) {
486
518
  const panels = flicking.renderer.panels;
487
519
  const camera = flicking.camera;
@@ -502,6 +534,11 @@ abstract class Renderer {
502
534
  });
503
535
  }
504
536
 
537
+ /**
538
+ * @internal
539
+ * @privateRemarks
540
+ * Calculates and applies panel sizes when {@link FlickingOptions.panelsPerView | panelsPerView} is enabled.
541
+ */
505
542
  protected _updatePanelSizeByGrid(referencePanel: Panel, panels: Panel[]) {
506
543
  const flicking = getFlickingAttached(this._flicking);
507
544
  const panelsPerView = flicking.panelsPerView;
@@ -515,9 +552,7 @@ abstract class Renderer {
515
552
  const gap = referencePanel.margin.prev + referencePanel.margin.next;
516
553
 
517
554
  const panelSize = (viewportSize - gap * (panelsPerView - 1)) / panelsPerView;
518
- const panelSizeObj = flicking.horizontal
519
- ? { width: panelSize }
520
- : { height: panelSize };
555
+ const panelSizeObj = flicking.horizontal ? { width: panelSize } : { height: panelSize };
521
556
  const firstPanelSizeObj = {
522
557
  size: panelSize,
523
558
  margin: referencePanel.margin,
@@ -531,6 +566,11 @@ abstract class Renderer {
531
566
  flicking.panels.forEach(panel => panel.resize(firstPanelSizeObj));
532
567
  }
533
568
 
569
+ /**
570
+ * @internal
571
+ * @privateRemarks
572
+ * Removes all child elements from the camera element.
573
+ */
534
574
  protected _removeAllChildsFromCamera() {
535
575
  const flicking = getFlickingAttached(this._flicking);
536
576
  const cameraElement = flicking.camera.element;
@@ -541,6 +581,11 @@ abstract class Renderer {
541
581
  }
542
582
  }
543
583
 
584
+ /**
585
+ * @internal
586
+ * @privateRemarks
587
+ * Inserts panel elements into the camera element at the specified position.
588
+ */
544
589
  protected _insertPanelElements(panels: Panel[], nextSibling: Panel | null = null) {
545
590
  const flicking = getFlickingAttached(this._flicking);
546
591
  const camera = flicking.camera;
@@ -552,6 +597,11 @@ abstract class Renderer {
552
597
  cameraElement.insertBefore(fragment, nextSiblingElement);
553
598
  }
554
599
 
600
+ /**
601
+ * @internal
602
+ * @privateRemarks
603
+ * Removes panel elements from the camera element.
604
+ */
555
605
  protected _removePanelElements(panels: Panel[]) {
556
606
  const flicking = getFlickingAttached(this._flicking);
557
607
  const cameraElement = flicking.camera.element;
@@ -561,6 +611,11 @@ abstract class Renderer {
561
611
  });
562
612
  }
563
613
 
614
+ /**
615
+ * @internal
616
+ * @privateRemarks
617
+ * Called after rendering to apply the camera transform.
618
+ */
564
619
  protected _afterRender() {
565
620
  const flicking = getFlickingAttached(this._flicking);
566
621
 
@@ -2,14 +2,12 @@
2
2
  * Copyright (c) 2015 NAVER Corp.
3
3
  * egjs projects are licensed under the MIT license
4
4
  */
5
- import { getFlickingAttached, toArray } from "../utils";
5
+
6
6
  import Panel, { PanelOptions } from "../core/panel/Panel";
7
+ import { getFlickingAttached, toArray } from "../utils";
7
8
 
8
9
  import Renderer from "./Renderer";
9
10
 
10
- /**
11
- *
12
- */
13
11
  class VanillaRenderer extends Renderer {
14
12
  // eslint-disable-next-line @typescript-eslint/require-await
15
13
  public async render() {
@@ -35,21 +33,23 @@ class VanillaRenderer extends Renderer {
35
33
  return this._strategy.createPanel(el, options);
36
34
  }
37
35
 
36
+ /**
37
+ * @internal
38
+ */
38
39
  private _resetPanelElementOrder() {
39
40
  const flicking = getFlickingAttached(this._flicking);
40
41
  const cameraEl = flicking.camera.element;
41
42
 
42
43
  // We're using reversed panels here as last panel should be the last element of camera element
43
-
44
44
  let reversedElements: HTMLElement[] = [];
45
45
 
46
46
  if (flicking.useCSSOrder) {
47
47
  // useCSSOrder를 사용하는 경우 DOM은 변화가 없지만 대신 css `order`값을 주입
48
- reversedElements = this.getRenderedPanels().map(panel => panel.element).reverse();
49
- } else {
50
- reversedElements = this._strategy
51
- .getRenderingElementsByOrder(flicking)
48
+ reversedElements = this.getRenderedPanels()
49
+ .map(panel => panel.element)
52
50
  .reverse();
51
+ } else {
52
+ reversedElements = this._strategy.getRenderingElementsByOrder(flicking).reverse();
53
53
  }
54
54
 
55
55
  reversedElements.forEach((el, idx) => {
@@ -61,6 +61,9 @@ class VanillaRenderer extends Renderer {
61
61
  });
62
62
  }
63
63
 
64
+ /**
65
+ * @internal
66
+ */
64
67
  private _removeAllTextNodes() {
65
68
  const flicking = getFlickingAttached(this._flicking);
66
69
  const cameraElement = flicking.camera.element;
@@ -2,18 +2,13 @@
2
2
  * Copyright (c) 2015 NAVER Corp.
3
3
  * egjs projects are licensed under the MIT license
4
4
  */
5
+
6
+ import ExternalRenderer from "./ExternalRenderer";
5
7
  import Renderer, { RendererOptions } from "./Renderer";
6
8
  import VanillaRenderer from "./VanillaRenderer";
7
- import ExternalRenderer from "./ExternalRenderer";
8
9
 
9
10
  export * from "./strategy";
10
11
 
11
- export {
12
- Renderer,
13
- VanillaRenderer,
14
- ExternalRenderer
15
- };
12
+ export { Renderer, VanillaRenderer, ExternalRenderer };
16
13
 
17
- export type {
18
- RendererOptions
19
- };
14
+ export type { RendererOptions };
@@ -2,10 +2,11 @@
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
+ import { DIRECTION } from "../../constants/values";
6
7
  import Panel, { PanelOptions } from "../../core/panel/Panel";
7
8
  import ElementProvider from "../../core/panel/provider/ElementProvider";
8
- import { DIRECTION } from "../../const/external";
9
+ import Flicking from "../../Flicking";
9
10
  import { parsePanelAlign } from "../../utils";
10
11
 
11
12
  import RenderingStrategy from "./RenderingStrategy";
@@ -14,11 +15,11 @@ export interface NormalRenderingStrategyOptions {
14
15
  providerCtor: new (...args: any) => ElementProvider;
15
16
  }
16
17
 
17
-
18
18
  class NormalRenderingStrategy implements RenderingStrategy {
19
19
  private _providerCtor: NormalRenderingStrategyOptions["providerCtor"];
20
20
 
21
- public constructor({ providerCtor }: NormalRenderingStrategyOptions) {
21
+ public constructor(options: NormalRenderingStrategyOptions) {
22
+ const { providerCtor } = options;
22
23
  this._providerCtor = providerCtor;
23
24
  }
24
25
 
@@ -49,37 +50,40 @@ class NormalRenderingStrategy implements RenderingStrategy {
49
50
  }
50
51
  }
51
52
 
52
- public collectPanels(
53
- flicking: Flicking,
54
- elements: any[]
55
- ) {
53
+ public collectPanels(flicking: Flicking, elements: any[]) {
56
54
  const align = parsePanelAlign(flicking.renderer.align);
57
55
 
58
- return elements.map((el, index) => new Panel({
59
- index,
60
- elementProvider: new this._providerCtor(el),
61
- align,
62
- flicking
63
- }));
56
+ return elements.map(
57
+ (el, index) =>
58
+ new Panel({
59
+ index,
60
+ elementProvider: new this._providerCtor(el),
61
+ align,
62
+ flicking
63
+ })
64
+ );
64
65
  }
65
66
 
66
- public createPanel(
67
- element: any,
68
- options: Omit<PanelOptions, "elementProvider">
69
- ) {
67
+ public createPanel(element: any, options: Omit<PanelOptions, "elementProvider">) {
70
68
  return new Panel({
71
69
  ...options,
72
70
  elementProvider: new this._providerCtor(element)
73
71
  });
74
72
  }
75
73
 
76
- public updatePanelSizes(flicking: Flicking, size: Partial<{
77
- width: number | string;
78
- height: number | string;
79
- }>) {
74
+ public updatePanelSizes(
75
+ flicking: Flicking,
76
+ size: Partial<{
77
+ width: number | string;
78
+ height: number | string;
79
+ }>
80
+ ) {
80
81
  flicking.panels.forEach(panel => panel.setSize(size));
81
82
  }
82
83
 
84
+ /**
85
+ * @internal
86
+ */
83
87
  private _showOnlyVisiblePanels(flicking: Flicking) {
84
88
  const panels = flicking.renderer.panels;
85
89
  const camera = flicking.camera;