@egjs/flicking 4.15.0 → 4.16.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/README.md +6 -175
  2. package/{declaration → dist}/CrossFlicking.d.ts +7 -2
  3. package/dist/Flicking.d.ts +1231 -0
  4. package/dist/camera/Camera.d.ts +324 -0
  5. package/{declaration → dist}/camera/mode/BoundCameraMode.d.ts +5 -4
  6. package/{declaration → dist}/camera/mode/CameraMode.d.ts +7 -6
  7. package/{declaration → dist}/camera/mode/CircularCameraMode.d.ts +9 -5
  8. package/{declaration → dist}/camera/mode/LinearCameraMode.d.ts +2 -4
  9. package/{declaration → dist}/cfc/getDefaultCameraTransform.d.ts +1 -1
  10. package/dist/cfc/withFlickingMethods.d.ts +15 -0
  11. package/{declaration/const/axes.d.ts → dist/constants/internal.d.ts} +8 -0
  12. package/dist/constants/values.d.ts +67 -0
  13. package/dist/control/AxesController.d.ts +186 -0
  14. package/dist/control/Control.d.ts +185 -0
  15. package/dist/control/FreeControl.d.ts +44 -0
  16. package/dist/control/SnapControl.d.ts +54 -0
  17. package/{declaration → dist}/control/StateMachine.d.ts +3 -0
  18. package/dist/control/StrictControl.d.ts +60 -0
  19. package/{declaration → dist}/control/states/AnimatingState.d.ts +12 -0
  20. package/{declaration → dist}/control/states/DisabledState.d.ts +12 -0
  21. package/{declaration → dist}/control/states/DraggingState.d.ts +12 -0
  22. package/{declaration → dist}/control/states/HoldingState.d.ts +12 -0
  23. package/{declaration → dist}/control/states/IdleState.d.ts +12 -0
  24. package/dist/control/states/State.d.ts +86 -0
  25. package/dist/core/AnchorPoint.d.ts +40 -0
  26. package/{declaration → dist}/core/AutoResizer.d.ts +6 -0
  27. package/dist/core/Viewport.d.ts +60 -0
  28. package/dist/core/VirtualManager.d.ts +84 -0
  29. package/dist/core/index.d.ts +6 -0
  30. package/dist/core/panel/Panel.d.ts +298 -0
  31. package/dist/core/panel/VirtualPanel.d.ts +41 -0
  32. package/dist/core/panel/index.d.ts +5 -0
  33. package/{declaration → dist}/core/panel/provider/VanillaElementProvider.d.ts +3 -0
  34. package/{declaration → dist}/core/panel/provider/VirtualElementProvider.d.ts +3 -0
  35. package/dist/error/FlickingError.d.ts +25 -0
  36. package/dist/error/codes.d.ts +79 -0
  37. package/dist/error/groups.d.ts +94 -0
  38. package/dist/error/index.d.ts +4 -0
  39. package/dist/error/types.d.ts +516 -0
  40. package/dist/event/groups.d.ts +40 -0
  41. package/dist/event/index.d.ts +3 -0
  42. package/dist/event/names.d.ts +47 -0
  43. package/dist/event/types.d.ts +318 -0
  44. package/dist/flicking.cjs.js +5559 -7791
  45. package/dist/flicking.cjs.js.map +1 -1
  46. package/dist/flicking.esm.js +5637 -7699
  47. package/dist/flicking.esm.js.map +1 -1
  48. package/dist/flicking.js +6722 -8893
  49. package/dist/flicking.js.map +1 -1
  50. package/dist/flicking.min.js +1 -9
  51. package/dist/flicking.min.js.map +1 -1
  52. package/dist/flicking.pkgd.js +9661 -14086
  53. package/dist/flicking.pkgd.js.map +1 -1
  54. package/dist/flicking.pkgd.min.js +1 -9
  55. package/dist/flicking.pkgd.min.js.map +1 -1
  56. package/dist/index.d.ts +16 -0
  57. package/dist/reactive/index.d.ts +126 -0
  58. package/{declaration → dist}/renderer/ExternalRenderer.d.ts +3 -0
  59. package/dist/renderer/Renderer.d.ts +215 -0
  60. package/{declaration → dist}/renderer/VanillaRenderer.d.ts +6 -0
  61. package/{declaration → dist}/renderer/strategy/NormalRenderingStrategy.d.ts +5 -2
  62. package/{declaration → dist}/renderer/strategy/RenderingStrategy.d.ts +4 -1
  63. package/dist/types/external.d.ts +58 -0
  64. package/dist/types/params.d.ts +10 -0
  65. package/{declaration → dist}/utils.d.ts +7 -7
  66. package/package.json +35 -162
  67. package/src/CrossFlicking.ts +68 -96
  68. package/src/Flicking.ts +1051 -972
  69. package/src/camera/Camera.ts +217 -206
  70. package/src/camera/index.ts +2 -6
  71. package/src/camera/mode/BoundCameraMode.ts +38 -27
  72. package/src/camera/mode/CameraMode.ts +14 -12
  73. package/src/camera/mode/CircularCameraMode.ts +24 -16
  74. package/src/camera/mode/LinearCameraMode.ts +3 -1
  75. package/src/camera/mode/index.ts +4 -10
  76. package/src/cfc/getDefaultCameraTransform.ts +9 -11
  77. package/src/cfc/getRenderingPanels.ts +2 -4
  78. package/src/cfc/index.ts +4 -9
  79. package/src/cfc/sync.ts +11 -5
  80. package/src/cfc/withFlickingMethods.ts +6 -7
  81. package/src/{const/axes.ts → constants/internal.ts} +1 -0
  82. package/src/constants/values.ts +78 -0
  83. package/src/control/AxesController.ts +119 -110
  84. package/src/control/Control.ts +147 -180
  85. package/src/control/FreeControl.ts +36 -60
  86. package/src/control/SnapControl.ts +64 -68
  87. package/src/control/StateMachine.ts +14 -11
  88. package/src/control/StrictControl.ts +58 -73
  89. package/src/control/index.ts +9 -12
  90. package/src/control/states/AnimatingState.ts +8 -11
  91. package/src/control/states/DisabledState.ts +0 -5
  92. package/src/control/states/DraggingState.ts +8 -12
  93. package/src/control/states/HoldingState.ts +10 -15
  94. package/src/control/states/IdleState.ts +1 -6
  95. package/src/control/states/State.ts +46 -85
  96. package/src/core/AnchorPoint.ts +25 -23
  97. package/src/core/AutoResizer.ts +6 -15
  98. package/src/core/ResizeWatcher.ts +17 -16
  99. package/src/core/Viewport.ts +35 -46
  100. package/src/core/VirtualManager.ts +48 -36
  101. package/src/core/index.ts +6 -9
  102. package/src/core/panel/Panel.ts +190 -185
  103. package/src/core/panel/VirtualPanel.ts +17 -21
  104. package/src/core/panel/index.ts +4 -9
  105. package/src/core/panel/provider/VanillaElementProvider.ts +6 -2
  106. package/src/core/panel/provider/VirtualElementProvider.ts +6 -2
  107. package/src/core/panel/provider/index.ts +2 -7
  108. package/src/{core → error}/FlickingError.ts +5 -7
  109. package/src/error/codes.ts +164 -0
  110. package/src/error/groups.ts +124 -0
  111. package/src/error/index.ts +9 -0
  112. package/src/error/types.ts +535 -0
  113. package/src/event/groups.ts +61 -0
  114. package/src/event/index.ts +8 -0
  115. package/src/event/names.ts +52 -0
  116. package/src/event/types.ts +355 -0
  117. package/src/index.ts +9 -11
  118. package/src/index.umd.ts +9 -3
  119. package/src/reactive/index.ts +39 -74
  120. package/src/renderer/Renderer.ts +170 -115
  121. package/src/renderer/VanillaRenderer.ts +12 -9
  122. package/src/renderer/index.ts +4 -9
  123. package/src/renderer/strategy/NormalRenderingStrategy.ts +26 -22
  124. package/src/renderer/strategy/RenderingStrategy.ts +2 -1
  125. package/src/renderer/strategy/VirtualRenderingStrategy.ts +20 -13
  126. package/src/renderer/strategy/index.ts +4 -9
  127. package/src/types/external.ts +72 -0
  128. package/src/{type → types}/internal.ts +2 -5
  129. package/src/types/params.ts +15 -0
  130. package/src/utils.ts +37 -32
  131. package/CONTRIBUTING.md +0 -59
  132. package/NOTICE +0 -31
  133. package/core-packages-link.js +0 -75
  134. package/debug/reactive/index.html +0 -240
  135. package/declaration/Flicking.d.ts +0 -264
  136. package/declaration/camera/Camera.d.ts +0 -90
  137. package/declaration/cfc/withFlickingMethods.d.ts +0 -2
  138. package/declaration/const/error.d.ts +0 -34
  139. package/declaration/const/external.d.ts +0 -54
  140. package/declaration/control/AxesController.d.ts +0 -45
  141. package/declaration/control/Control.d.ts +0 -45
  142. package/declaration/control/FreeControl.d.ts +0 -14
  143. package/declaration/control/SnapControl.d.ts +0 -16
  144. package/declaration/control/StrictControl.d.ts +0 -20
  145. package/declaration/control/states/State.d.ts +0 -47
  146. package/declaration/core/AnchorPoint.d.ts +0 -15
  147. package/declaration/core/FlickingError.d.ts +0 -5
  148. package/declaration/core/Viewport.d.ts +0 -25
  149. package/declaration/core/VirtualManager.d.ts +0 -37
  150. package/declaration/core/index.d.ts +0 -6
  151. package/declaration/core/panel/Panel.d.ts +0 -89
  152. package/declaration/core/panel/VirtualPanel.d.ts +0 -19
  153. package/declaration/core/panel/index.d.ts +0 -5
  154. package/declaration/index.d.ts +0 -16
  155. package/declaration/reactive/index.d.ts +0 -25
  156. package/declaration/renderer/Renderer.d.ts +0 -60
  157. package/declaration/type/event.d.ts +0 -88
  158. package/declaration/type/external.d.ts +0 -31
  159. package/jsconfig.json +0 -5
  160. package/jsdoc-to-mdx.json +0 -7
  161. package/rollup.config.demo.js +0 -24
  162. package/rollup.config.dev.js +0 -12
  163. package/rollup.config.js +0 -57
  164. package/src/const/error.ts +0 -64
  165. package/src/const/external.ts +0 -138
  166. package/src/type/event.ts +0 -315
  167. package/src/type/external.ts +0 -78
  168. package/tsconfig.declaration.json +0 -17
  169. package/tsconfig.eslint.json +0 -10
  170. package/tsconfig.json +0 -23
  171. package/{declaration → dist}/camera/index.d.ts +0 -0
  172. package/{declaration → dist}/camera/mode/index.d.ts +2 -2
  173. package/{declaration → dist}/cfc/getRenderingPanels.d.ts +0 -0
  174. package/{declaration → dist}/cfc/index.d.ts +3 -3
  175. package/{declaration → dist}/cfc/sync.d.ts +0 -0
  176. package/{declaration → dist}/control/index.d.ts +7 -7
  177. package/{declaration → dist}/core/ResizeWatcher.d.ts +0 -0
  178. package/{declaration → dist}/core/panel/provider/ElementProvider.d.ts +0 -0
  179. package/{declaration → dist}/core/panel/provider/index.d.ts +0 -0
  180. package/{declaration → dist}/index.cjs.d.ts +0 -0
  181. package/{declaration → dist}/index.umd.d.ts +0 -0
  182. package/{declaration → dist}/renderer/index.d.ts +1 -1
  183. package/{declaration → dist}/renderer/strategy/VirtualRenderingStrategy.d.ts +1 -1
  184. package/{declaration → dist}/renderer/strategy/index.d.ts +1 -1
  185. /package/{declaration/type → dist/types}/internal.d.ts +0 -0
@@ -4,12 +4,8 @@
4
4
  */
5
5
  import Camera, { CameraOptions } from "./Camera";
6
6
 
7
- export {
8
- Camera
9
- };
7
+ export { Camera };
10
8
 
11
- export type {
12
- CameraOptions
13
- };
9
+ export type { CameraOptions };
14
10
 
15
11
  export * from "./mode";
@@ -5,6 +5,7 @@
5
5
  import AnchorPoint from "../../core/AnchorPoint";
6
6
  import Panel from "../../core/panel/Panel";
7
7
  import { parseAlign } from "../../utils";
8
+ import { CameraRange } from "../Camera";
8
9
 
9
10
  import CameraMode from "./CameraMode";
10
11
 
@@ -29,7 +30,7 @@ class BoundCameraMode extends CameraMode {
29
30
  return isBiggerThanViewport;
30
31
  }
31
32
 
32
- public getRange(): { min: number; max: number } {
33
+ public getRange(): CameraRange {
33
34
  const flicking = this._flicking;
34
35
  const renderer = flicking.renderer;
35
36
  const alignPos = flicking.camera.alignPosition;
@@ -54,9 +55,7 @@ class BoundCameraMode extends CameraMode {
54
55
  return { min: firstPos, max: lastPos };
55
56
  } else {
56
57
  const align = flicking.camera.align;
57
- const alignVal = typeof align === "object"
58
- ? (align as { camera: string | number }).camera
59
- : align;
58
+ const alignVal = typeof align === "object" ? (align as { camera: string | number }).camera : align;
60
59
 
61
60
  const pos = firstPos + parseAlign(alignVal, lastPos - firstPos);
62
61
 
@@ -81,35 +80,42 @@ class BoundCameraMode extends CameraMode {
81
80
  const shouldAppendBoundAnchor = reachablePanels[reachablePanels.length - 1].position !== range.max;
82
81
  const indexOffset = shouldPrependBoundAnchor ? 1 : 0;
83
82
 
84
- const newAnchors = reachablePanels.map((panel, idx) => new AnchorPoint({
85
- index: idx + indexOffset,
86
- position: panel.position,
87
- panel
88
- }));
83
+ const newAnchors = reachablePanels.map(
84
+ (panel, idx) =>
85
+ new AnchorPoint({
86
+ index: idx + indexOffset,
87
+ position: panel.position,
88
+ panel
89
+ })
90
+ );
89
91
 
90
92
  if (shouldPrependBoundAnchor) {
91
- newAnchors.splice(0, 0, new AnchorPoint({
92
- index: 0,
93
- position: range.min,
94
- panel: panels[reachablePanels[0].index - 1]
95
- }));
93
+ newAnchors.splice(
94
+ 0,
95
+ 0,
96
+ new AnchorPoint({
97
+ index: 0,
98
+ position: range.min,
99
+ panel: panels[reachablePanels[0].index - 1]
100
+ })
101
+ );
96
102
  }
97
103
 
98
104
  if (shouldAppendBoundAnchor) {
99
- newAnchors.push(new AnchorPoint({
100
- index: newAnchors.length,
101
- position: range.max,
102
- panel: panels[reachablePanels[reachablePanels.length - 1].index + 1]
103
- }));
105
+ newAnchors.push(
106
+ new AnchorPoint({
107
+ index: newAnchors.length,
108
+ position: range.max,
109
+ panel: panels[reachablePanels[reachablePanels.length - 1].index + 1]
110
+ })
111
+ );
104
112
  }
105
113
 
106
114
  return newAnchors;
107
115
  } else if (range.min !== range.max) {
108
116
  // There're more than 2 panels
109
117
  const nearestPanelAtMin = this._findNearestPanel(range.min, panels);
110
- const panelAtMin = nearestPanelAtMin.index === panels.length - 1
111
- ? nearestPanelAtMin.prev()!
112
- : nearestPanelAtMin;
118
+ const panelAtMin = nearestPanelAtMin.index === panels.length - 1 ? nearestPanelAtMin.prev()! : nearestPanelAtMin;
113
119
  const panelAtMax = panelAtMin.next()!;
114
120
 
115
121
  return [
@@ -125,11 +131,13 @@ class BoundCameraMode extends CameraMode {
125
131
  })
126
132
  ];
127
133
  } else {
128
- return [new AnchorPoint({
129
- index: 0,
130
- position: range.min,
131
- panel: this._findNearestPanel(range.min, panels)
132
- })];
134
+ return [
135
+ new AnchorPoint({
136
+ index: 0,
137
+ position: range.min,
138
+ panel: this._findNearestPanel(range.min, panels)
139
+ })
140
+ ];
133
141
  }
134
142
  }
135
143
 
@@ -149,6 +157,9 @@ class BoundCameraMode extends CameraMode {
149
157
  }
150
158
  }
151
159
 
160
+ /**
161
+ * @internal
162
+ */
152
163
  private _findNearestPanel(pos: number, panels: Panel[]): Panel {
153
164
  let prevDist = Infinity;
154
165
  for (let panelIdx = 0; panelIdx < panels.length; panelIdx++) {
@@ -2,10 +2,12 @@
2
2
  * Copyright (c) 2015 NAVER Corp.
3
3
  * egjs projects are licensed under the MIT license
4
4
  */
5
- import Flicking from "../../Flicking";
6
- import Panel from "../../core/panel/Panel";
5
+
7
6
  import AnchorPoint from "../../core/AnchorPoint";
7
+ import Panel from "../../core/panel/Panel";
8
+ import Flicking from "../../Flicking";
8
9
  import { clamp } from "../../utils";
10
+ import { CameraRange } from "../Camera";
9
11
 
10
12
  /**
11
13
  * A mode of camera
@@ -13,22 +15,24 @@ import { clamp } from "../../utils";
13
15
  abstract class CameraMode {
14
16
  protected _flicking: Flicking;
15
17
 
16
- /** */
17
18
  public constructor(flicking: Flicking) {
18
19
  this._flicking = flicking;
19
20
  }
20
21
 
21
22
  public abstract checkAvailability(): boolean;
22
- public abstract getRange(): { min: number; max: number };
23
+ public abstract getRange(): CameraRange;
23
24
 
24
25
  public getAnchors(): AnchorPoint[] {
25
26
  const panels = this._flicking.renderer.panels;
26
27
 
27
- return panels.map((panel, index) => new AnchorPoint({
28
- index,
29
- position: panel.position,
30
- panel
31
- }));
28
+ return panels.map(
29
+ (panel, index) =>
30
+ new AnchorPoint({
31
+ index,
32
+ position: panel.position,
33
+ panel
34
+ })
35
+ );
32
36
  }
33
37
 
34
38
  public findAnchorIncludePosition(position: number): AnchorPoint | null {
@@ -38,9 +42,7 @@ abstract class CameraMode {
38
42
  return anchorsIncludingPosition.reduce((nearest: AnchorPoint | null, anchor) => {
39
43
  if (!nearest) return anchor;
40
44
 
41
- return Math.abs(nearest.position - position) < Math.abs(anchor.position - position)
42
- ? nearest
43
- : anchor;
45
+ return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
44
46
  }, null);
45
47
  }
46
48
 
@@ -2,16 +2,17 @@
2
2
  * Copyright (c) 2015 NAVER Corp.
3
3
  * egjs projects are licensed under the MIT license
4
4
  */
5
- import Panel from "../../core/panel/Panel";
5
+
6
+ import { DIRECTION } from "../../constants/values";
6
7
  import AnchorPoint from "../../core/AnchorPoint";
7
- import { DIRECTION } from "../../const/external";
8
+ import Panel from "../../core/panel/Panel";
8
9
  import { circulatePosition } from "../../utils";
10
+ import { CameraRange } from "../Camera";
9
11
 
10
12
  import CameraMode from "./CameraMode";
11
13
 
12
14
  /**
13
15
  * A {@link Camera} mode that connects the last panel and the first panel, enabling continuous loop
14
- * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera} 모드
15
16
  */
16
17
  class CircularCameraMode extends CameraMode {
17
18
  public checkAvailability(): boolean {
@@ -31,13 +32,12 @@ class CircularCameraMode extends CameraMode {
31
32
  const visibleSize = flicking.camera.size;
32
33
  const panelSizeSum = lastPanelNext - firstPanelPrev;
33
34
 
34
- const canSetCircularMode = panels
35
- .every(panel => panelSizeSum - panel.size >= visibleSize);
35
+ const canSetCircularMode = panels.every(panel => panelSizeSum - panel.size >= visibleSize);
36
36
 
37
37
  return canSetCircularMode;
38
38
  }
39
39
 
40
- public getRange(): { min: number; max: number } {
40
+ public getRange(): CameraRange {
41
41
  const flicking = this._flicking;
42
42
  const panels = flicking.renderer.panels;
43
43
 
@@ -57,11 +57,14 @@ class CircularCameraMode extends CameraMode {
57
57
  const flicking = this._flicking;
58
58
  const panels = flicking.renderer.panels;
59
59
 
60
- return panels.map((panel, index) => new AnchorPoint({
61
- index,
62
- position: panel.position,
63
- panel
64
- }));
60
+ return panels.map(
61
+ (panel, index) =>
62
+ new AnchorPoint({
63
+ index,
64
+ position: panel.position,
65
+ panel
66
+ })
67
+ );
65
68
  }
66
69
 
67
70
  public findNearestAnchor(position: number): AnchorPoint | null {
@@ -119,9 +122,7 @@ class CircularCameraMode extends CameraMode {
119
122
  anchorInRange = possibleAnchors.reduce((nearest: AnchorPoint | null, anchor) => {
120
123
  if (!nearest) return anchor;
121
124
 
122
- return Math.abs(nearest.position - position) < Math.abs(anchor.position - position)
123
- ? nearest
124
- : anchor;
125
+ return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
125
126
  }, null);
126
127
  }
127
128
 
@@ -182,14 +183,21 @@ class CircularCameraMode extends CameraMode {
182
183
 
183
184
  // Check looped visible area for circular case
184
185
  if (visibleRange.min < range.min) {
185
- return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min + rangeDiff, visibleRange.max + rangeDiff);
186
+ return (
187
+ visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min + rangeDiff, visibleRange.max + rangeDiff)
188
+ );
186
189
  } else if (visibleRange.max > range.max) {
187
- return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min - rangeDiff, visibleRange.max - rangeDiff);
190
+ return (
191
+ visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min - rangeDiff, visibleRange.max - rangeDiff)
192
+ );
188
193
  }
189
194
 
190
195
  return visibleInCurrentRange;
191
196
  }
192
197
 
198
+ /**
199
+ * @internal
200
+ */
193
201
  private _calcPanelAreaSum(panels: Panel[]) {
194
202
  return panels.reduce((sum: number, panel: Panel) => sum + panel.sizeIncludingMargin, 0);
195
203
  }
@@ -2,6 +2,8 @@
2
2
  * Copyright (c) 2015 NAVER Corp.
3
3
  * egjs projects are licensed under the MIT license
4
4
  */
5
+ import { CameraRange } from "../Camera";
6
+
5
7
  import CameraMode from "./CameraMode";
6
8
 
7
9
  class LinearCameraMode extends CameraMode {
@@ -10,7 +12,7 @@ class LinearCameraMode extends CameraMode {
10
12
  return true;
11
13
  }
12
14
 
13
- public getRange(): { min: number; max: number } {
15
+ public getRange(): CameraRange {
14
16
  const renderer = this._flicking.renderer;
15
17
 
16
18
  const firstPanel = renderer.getPanel(0);
@@ -1,14 +1,8 @@
1
+ import BoundCameraMode from "./BoundCameraMode";
1
2
  import CameraMode from "./CameraMode";
2
- import LinearCameraMode from "./LinearCameraMode";
3
3
  import CircularCameraMode from "./CircularCameraMode";
4
- import BoundCameraMode from "./BoundCameraMode";
4
+ import LinearCameraMode from "./LinearCameraMode";
5
5
 
6
- export {
7
- LinearCameraMode,
8
- CircularCameraMode,
9
- BoundCameraMode
10
- };
6
+ export { LinearCameraMode, CircularCameraMode, BoundCameraMode };
11
7
 
12
- export type {
13
- CameraMode
14
- };
8
+ export type { CameraMode };
@@ -1,8 +1,12 @@
1
+ import { ALIGN } from "../constants/values";
1
2
  import { FlickingOptions } from "../Flicking";
2
- import { ALIGN } from "../const/external";
3
3
  import { parseArithmeticExpression } from "../utils";
4
4
 
5
- export default (align: FlickingOptions["align"] = ALIGN.CENTER, horizontal: boolean = true, firstPanelSize?: string) => {
5
+ export default (
6
+ align: FlickingOptions["align"] = ALIGN.CENTER,
7
+ horizontal: boolean = true,
8
+ firstPanelSize?: string
9
+ ) => {
6
10
  const cameraAlign = getCameraAlign(align);
7
11
  const panelAlign = getPanelAlign(align);
8
12
 
@@ -10,23 +14,17 @@ export default (align: FlickingOptions["align"] = ALIGN.CENTER, horizontal: bool
10
14
 
11
15
  const camPosition = `calc(${cameraAlign} - (${firstPanelSize || "0px"} * ${panelAlign.percentage}) - ${panelAlign.absolute}px)`;
12
16
 
13
- return horizontal
14
- ? `translate(${camPosition})`
15
- : `translate(0, ${camPosition})`;
17
+ return horizontal ? `translate(${camPosition})` : `translate(0, ${camPosition})`;
16
18
  };
17
19
 
18
20
  const getCameraAlign = (align: FlickingOptions["align"]) => {
19
- const alignVal = typeof align === "object"
20
- ? (align as { camera: string | number }).camera
21
- : align;
21
+ const alignVal = typeof align === "object" ? (align as { camera: string | number }).camera : align;
22
22
 
23
23
  return parseAlign(alignVal);
24
24
  };
25
25
 
26
26
  const getPanelAlign = (align: FlickingOptions["align"]) => {
27
- const alignVal = typeof align === "object"
28
- ? (align as { panel: string | number }).panel
29
- : align;
27
+ const alignVal = typeof align === "object" ? (align as { panel: string | number }).panel : align;
30
28
 
31
29
  return parseArithmeticExpression(parseAlign(alignVal));
32
30
  };
@@ -12,13 +12,11 @@ export default <T>(flicking: Flicking, diffResult: DiffResult<T>) => {
12
12
  map[prev] = current;
13
13
  return map;
14
14
  }, {});
15
- const renderingPanels = flicking.panels
16
- .filter(panel => !removedPanels[panel.index]);
17
-
15
+ const renderingPanels = flicking.panels.filter(panel => !removedPanels[panel.index]);
18
16
 
19
17
  if (!flicking.useCSSOrder) {
20
18
  // useCSSOrder를 사용하게 되는 경우 sort를 하지 않는다.
21
- renderingPanels.sort((panel1, panel2) => (panel1.position + panel1.offset) - (panel2.position + panel2.offset));
19
+ renderingPanels.sort((panel1, panel2) => panel1.position + panel1.offset - (panel2.position + panel2.offset));
22
20
  }
23
21
 
24
22
  return [
package/src/cfc/index.ts CHANGED
@@ -1,11 +1,6 @@
1
- import withFlickingMethods from "./withFlickingMethods";
2
- import sync from "./sync";
3
- import getRenderingPanels from "./getRenderingPanels";
4
1
  import getDefaultCameraTransform from "./getDefaultCameraTransform";
2
+ import getRenderingPanels from "./getRenderingPanels";
3
+ import sync from "./sync";
4
+ import withFlickingMethods from "./withFlickingMethods";
5
5
 
6
- export {
7
- withFlickingMethods,
8
- sync,
9
- getRenderingPanels,
10
- getDefaultCameraTransform
11
- };
6
+ export { withFlickingMethods, sync, getRenderingPanels, getDefaultCameraTransform };
package/src/cfc/sync.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { DiffResult } from "@egjs/list-differ";
2
-
2
+ import Panel from "../core/panel/Panel";
3
3
  import Flicking from "../Flicking";
4
4
  import Renderer from "../renderer/Renderer";
5
- import Panel from "../core/panel/Panel";
6
5
 
7
6
  export default (flicking: Flicking, diffResult: DiffResult<any>, rendered: any[]) => {
8
7
  const renderer = flicking.renderer;
@@ -100,9 +99,17 @@ export default (flicking: Flicking, diffResult: DiffResult<any>, rendered: any[]
100
99
  }
101
100
  };
102
101
 
103
- const batchInsert = (renderer: Renderer, diffResult: DiffResult<any>, addedElements: any[], startIdx: number, endIdx?: number) => {
102
+ const batchInsert = (
103
+ renderer: Renderer,
104
+ diffResult: DiffResult<any>,
105
+ addedElements: any[],
106
+ startIdx: number,
107
+ endIdx?: number
108
+ ) => {
104
109
  return renderer.batchInsertDefer(
105
- ...diffResult.added.slice(startIdx, endIdx).map((index, elIdx) => ({ index, elements: [addedElements[elIdx]], hasDOMInElements: false }))
110
+ ...diffResult.added
111
+ .slice(startIdx, endIdx)
112
+ .map((index, elIdx) => ({ index, elements: [addedElements[elIdx]], hasDOMInElements: false }))
106
113
  );
107
114
  };
108
115
 
@@ -111,4 +118,3 @@ const batchRemove = (renderer: Renderer, startIdx: number, endIdx?: number) => {
111
118
 
112
119
  return renderer.batchRemoveDefer({ index: startIdx, deleteCount: removed.length, hasDOMInElements: false });
113
120
  };
114
-
@@ -4,9 +4,7 @@ import Flicking from "../Flicking";
4
4
 
5
5
  /**
6
6
  * Decorator that makes the method of flicking available in the framework.
7
- * @ko 프레임워크에서 플리킹의 메소드를 사용할 수 있게 하는 데코레이터.
8
- * @memberof eg.Flicking
9
- * @private
7
+ * @internal
10
8
  * @example
11
9
  * ```js
12
10
  * import Flicking, { withFlickingMethods } from "@egjs/flicking";
@@ -19,27 +17,28 @@ import Flicking from "../Flicking";
19
17
  */
20
18
  const withFlickingMethods = (prototype: any, flickingName: string) => {
21
19
  [Component.prototype, Flicking.prototype].forEach(proto => {
22
- Object.getOwnPropertyNames(proto).filter(name => !prototype[name] && name.indexOf("_") !== 0 && name !== "constructor")
20
+ Object.getOwnPropertyNames(proto)
21
+ .filter(name => !prototype[name] && name.indexOf("_") !== 0 && name !== "constructor")
23
22
  .forEach((name: string) => {
24
23
  const descriptor = Object.getOwnPropertyDescriptor(proto, name)!;
25
24
 
26
25
  if (descriptor.value) {
27
26
  // Public Function
28
27
  Object.defineProperty(prototype, name, {
29
- value: function(...args) {
28
+ value: function (...args) {
30
29
  return descriptor.value.call(this[flickingName], ...args);
31
30
  }
32
31
  });
33
32
  } else {
34
33
  const getterDescriptor: { get?: () => any; set?: (val: any) => void } = {};
35
34
  if (descriptor.get) {
36
- getterDescriptor.get = function() {
35
+ getterDescriptor.get = function () {
37
36
  const flicking = this[flickingName];
38
37
  return flicking && descriptor.get?.call(flicking);
39
38
  };
40
39
  }
41
40
  if (descriptor.set) {
42
- getterDescriptor.set = function(...args) {
41
+ getterDescriptor.set = function (...args) {
43
42
  return descriptor.set?.call(this[flickingName], ...args);
44
43
  };
45
44
  }
@@ -1,3 +1,4 @@
1
+ /* @internal */
1
2
  /**
2
3
  * All possible @egjs/axes event keys
3
4
  * @internal
@@ -0,0 +1,78 @@
1
+ /*
2
+ * Copyright (c) 2015 NAVER Corp.
3
+ * egjs projects are licensed under the MIT license
4
+ */
5
+
6
+ /**
7
+ * An object with all possible predefined literal string for the {@link Flicking.align | align} option
8
+ */
9
+ export const ALIGN = {
10
+ /** left/top align */
11
+ PREV: "prev",
12
+ /** center align */
13
+ CENTER: "center",
14
+ /** right/bottom align */
15
+ NEXT: "next"
16
+ } as const;
17
+
18
+ /**
19
+ * An object of directions
20
+ */
21
+ export const DIRECTION = {
22
+ /** "left" when {@link Flicking.horizontal | horizontal} is true, and "top" when {@link Flicking.horizontal | horizontal} is false */
23
+ PREV: "PREV",
24
+ /** "right" when {@link Flicking.horizontal | horizontal} is true, and "bottom" when {@link Flicking.horizontal | horizontal} is false */
25
+ NEXT: "NEXT",
26
+ /** This value usually means it's the same position */
27
+ NONE: null
28
+ } as const;
29
+
30
+ /**
31
+ * An object with all possible {@link Flicking.moveType | moveType}s
32
+ */
33
+ export const MOVE_TYPE = {
34
+ /** Flicking's {@link Flicking.moveType | moveType} that enables {@link SnapControl} as a Flicking's {@link Flicking.control | control} */
35
+ SNAP: "snap",
36
+ /** Flicking's {@link Flicking.moveType | moveType} that enables {@link FreeControl} as a Flicking's {@link Flicking.control | control} */
37
+ FREE_SCROLL: "freeScroll",
38
+ /** Flicking's {@link Flicking.moveType | moveType} that enables {@link StrictControl} as a Flicking's {@link Flicking.control | control} */
39
+ STRICT: "strict"
40
+ } as const;
41
+
42
+ export const CLASS = {
43
+ VIEWPORT: "flicking-viewport",
44
+ CAMERA: "flicking-camera",
45
+ VERTICAL: "vertical",
46
+ HIDDEN: "flicking-hidden",
47
+ DEFAULT_VIRTUAL: "flicking-panel"
48
+ };
49
+
50
+ /**
51
+ * An object with all possible {@link Flicking.circularFallback | circularFallback}s
52
+ */
53
+ export const CIRCULAR_FALLBACK = {
54
+ /** "linear" */
55
+ LINEAR: "linear",
56
+ /** "bound" */
57
+ BOUND: "bound"
58
+ } as const;
59
+
60
+ /**
61
+ * An object for identifying {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction | direction} CSS property applied to the camera element(`.flicking-camera`)
62
+ */
63
+ export const ORDER = {
64
+ /** "ltr" */
65
+ LTR: "ltr",
66
+ /** "rtl" */
67
+ RTL: "rtl"
68
+ } as const;
69
+
70
+ /**
71
+ * An object that contains the direction that {@link Flicking} is moving
72
+ */
73
+ export const MOVE_DIRECTION = {
74
+ /** horizontal */
75
+ HORIZONTAL: "horizontal",
76
+ /** vertical */
77
+ VERTICAL: "vertical"
78
+ } as const;