@egjs/flicking 4.14.2-beta.2 → 4.16.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/README.md +6 -175
  2. package/{declaration → dist}/CrossFlicking.d.ts +7 -2
  3. package/dist/Flicking.d.ts +1231 -0
  4. package/dist/camera/Camera.d.ts +324 -0
  5. package/{declaration → dist}/camera/mode/BoundCameraMode.d.ts +5 -4
  6. package/{declaration → dist}/camera/mode/CameraMode.d.ts +7 -6
  7. package/{declaration → dist}/camera/mode/CircularCameraMode.d.ts +9 -5
  8. package/{declaration → dist}/camera/mode/LinearCameraMode.d.ts +2 -4
  9. package/{declaration → dist}/cfc/getDefaultCameraTransform.d.ts +1 -1
  10. package/dist/cfc/withFlickingMethods.d.ts +15 -0
  11. package/{declaration/const/axes.d.ts → dist/constants/internal.d.ts} +8 -0
  12. package/dist/constants/values.d.ts +67 -0
  13. package/dist/control/AxesController.d.ts +186 -0
  14. package/dist/control/Control.d.ts +185 -0
  15. package/dist/control/FreeControl.d.ts +44 -0
  16. package/dist/control/SnapControl.d.ts +54 -0
  17. package/{declaration → dist}/control/StateMachine.d.ts +3 -0
  18. package/dist/control/StrictControl.d.ts +60 -0
  19. package/{declaration → dist}/control/states/AnimatingState.d.ts +12 -0
  20. package/{declaration → dist}/control/states/DisabledState.d.ts +12 -0
  21. package/{declaration → dist}/control/states/DraggingState.d.ts +12 -0
  22. package/{declaration → dist}/control/states/HoldingState.d.ts +12 -0
  23. package/{declaration → dist}/control/states/IdleState.d.ts +12 -0
  24. package/dist/control/states/State.d.ts +86 -0
  25. package/dist/core/AnchorPoint.d.ts +40 -0
  26. package/{declaration → dist}/core/AutoResizer.d.ts +6 -0
  27. package/dist/core/Viewport.d.ts +60 -0
  28. package/dist/core/VirtualManager.d.ts +84 -0
  29. package/dist/core/index.d.ts +6 -0
  30. package/dist/core/panel/Panel.d.ts +298 -0
  31. package/dist/core/panel/VirtualPanel.d.ts +41 -0
  32. package/dist/core/panel/index.d.ts +5 -0
  33. package/{declaration → dist}/core/panel/provider/VanillaElementProvider.d.ts +3 -0
  34. package/{declaration → dist}/core/panel/provider/VirtualElementProvider.d.ts +3 -0
  35. package/dist/error/FlickingError.d.ts +25 -0
  36. package/dist/error/codes.d.ts +79 -0
  37. package/dist/error/groups.d.ts +94 -0
  38. package/dist/error/index.d.ts +4 -0
  39. package/dist/error/types.d.ts +516 -0
  40. package/dist/event/groups.d.ts +40 -0
  41. package/dist/event/index.d.ts +3 -0
  42. package/dist/event/names.d.ts +47 -0
  43. package/dist/event/types.d.ts +318 -0
  44. package/dist/flicking.cjs.js +5560 -7784
  45. package/dist/flicking.cjs.js.map +1 -1
  46. package/dist/flicking.esm.js +5638 -7692
  47. package/dist/flicking.esm.js.map +1 -1
  48. package/dist/flicking.js +6722 -8885
  49. package/dist/flicking.js.map +1 -1
  50. package/dist/flicking.min.js +1 -9
  51. package/dist/flicking.min.js.map +1 -1
  52. package/dist/flicking.pkgd.js +9661 -14078
  53. package/dist/flicking.pkgd.js.map +1 -1
  54. package/dist/flicking.pkgd.min.js +1 -9
  55. package/dist/flicking.pkgd.min.js.map +1 -1
  56. package/dist/index.d.ts +16 -0
  57. package/dist/reactive/index.d.ts +126 -0
  58. package/{declaration → dist}/renderer/ExternalRenderer.d.ts +3 -0
  59. package/dist/renderer/Renderer.d.ts +215 -0
  60. package/{declaration → dist}/renderer/VanillaRenderer.d.ts +6 -0
  61. package/{declaration → dist}/renderer/strategy/NormalRenderingStrategy.d.ts +5 -2
  62. package/{declaration → dist}/renderer/strategy/RenderingStrategy.d.ts +4 -1
  63. package/dist/types/external.d.ts +58 -0
  64. package/dist/types/params.d.ts +10 -0
  65. package/{declaration → dist}/utils.d.ts +7 -7
  66. package/package.json +35 -162
  67. package/src/CrossFlicking.ts +68 -96
  68. package/src/Flicking.ts +1055 -972
  69. package/src/camera/Camera.ts +217 -206
  70. package/src/camera/index.ts +2 -6
  71. package/src/camera/mode/BoundCameraMode.ts +38 -27
  72. package/src/camera/mode/CameraMode.ts +14 -12
  73. package/src/camera/mode/CircularCameraMode.ts +24 -16
  74. package/src/camera/mode/LinearCameraMode.ts +3 -1
  75. package/src/camera/mode/index.ts +4 -10
  76. package/src/cfc/getDefaultCameraTransform.ts +9 -11
  77. package/src/cfc/getRenderingPanels.ts +2 -5
  78. package/src/cfc/index.ts +4 -9
  79. package/src/cfc/sync.ts +11 -5
  80. package/src/cfc/withFlickingMethods.ts +6 -7
  81. package/src/{const/axes.ts → constants/internal.ts} +1 -0
  82. package/src/constants/values.ts +78 -0
  83. package/src/control/AxesController.ts +119 -110
  84. package/src/control/Control.ts +147 -180
  85. package/src/control/FreeControl.ts +36 -60
  86. package/src/control/SnapControl.ts +64 -68
  87. package/src/control/StateMachine.ts +14 -11
  88. package/src/control/StrictControl.ts +58 -73
  89. package/src/control/index.ts +9 -12
  90. package/src/control/states/AnimatingState.ts +8 -11
  91. package/src/control/states/DisabledState.ts +0 -5
  92. package/src/control/states/DraggingState.ts +8 -12
  93. package/src/control/states/HoldingState.ts +10 -15
  94. package/src/control/states/IdleState.ts +1 -6
  95. package/src/control/states/State.ts +46 -85
  96. package/src/core/AnchorPoint.ts +25 -23
  97. package/src/core/AutoResizer.ts +6 -15
  98. package/src/core/ResizeWatcher.ts +17 -16
  99. package/src/core/Viewport.ts +35 -46
  100. package/src/core/VirtualManager.ts +48 -36
  101. package/src/core/index.ts +6 -9
  102. package/src/core/panel/Panel.ts +190 -185
  103. package/src/core/panel/VirtualPanel.ts +17 -21
  104. package/src/core/panel/index.ts +4 -9
  105. package/src/core/panel/provider/VanillaElementProvider.ts +6 -2
  106. package/src/core/panel/provider/VirtualElementProvider.ts +6 -2
  107. package/src/core/panel/provider/index.ts +2 -7
  108. package/src/{core → error}/FlickingError.ts +5 -7
  109. package/src/error/codes.ts +164 -0
  110. package/src/error/groups.ts +124 -0
  111. package/src/error/index.ts +9 -0
  112. package/src/error/types.ts +535 -0
  113. package/src/event/groups.ts +61 -0
  114. package/src/event/index.ts +8 -0
  115. package/src/event/names.ts +52 -0
  116. package/src/event/types.ts +355 -0
  117. package/src/index.ts +9 -11
  118. package/src/index.umd.ts +9 -3
  119. package/src/reactive/index.ts +39 -74
  120. package/src/renderer/Renderer.ts +177 -119
  121. package/src/renderer/VanillaRenderer.ts +13 -10
  122. package/src/renderer/index.ts +4 -9
  123. package/src/renderer/strategy/NormalRenderingStrategy.ts +26 -22
  124. package/src/renderer/strategy/RenderingStrategy.ts +2 -1
  125. package/src/renderer/strategy/VirtualRenderingStrategy.ts +20 -13
  126. package/src/renderer/strategy/index.ts +4 -9
  127. package/src/types/external.ts +72 -0
  128. package/src/{type → types}/internal.ts +2 -5
  129. package/src/types/params.ts +15 -0
  130. package/src/utils.ts +37 -32
  131. package/CONTRIBUTING.md +0 -59
  132. package/NOTICE +0 -31
  133. package/core-packages-link.js +0 -75
  134. package/debug/reactive/index.html +0 -240
  135. package/declaration/Flicking.d.ts +0 -264
  136. package/declaration/camera/Camera.d.ts +0 -90
  137. package/declaration/cfc/withFlickingMethods.d.ts +0 -2
  138. package/declaration/const/error.d.ts +0 -34
  139. package/declaration/const/external.d.ts +0 -54
  140. package/declaration/control/AxesController.d.ts +0 -45
  141. package/declaration/control/Control.d.ts +0 -45
  142. package/declaration/control/FreeControl.d.ts +0 -14
  143. package/declaration/control/SnapControl.d.ts +0 -16
  144. package/declaration/control/StrictControl.d.ts +0 -20
  145. package/declaration/control/states/State.d.ts +0 -47
  146. package/declaration/core/AnchorPoint.d.ts +0 -15
  147. package/declaration/core/FlickingError.d.ts +0 -5
  148. package/declaration/core/Viewport.d.ts +0 -25
  149. package/declaration/core/VirtualManager.d.ts +0 -37
  150. package/declaration/core/index.d.ts +0 -6
  151. package/declaration/core/panel/Panel.d.ts +0 -89
  152. package/declaration/core/panel/VirtualPanel.d.ts +0 -19
  153. package/declaration/core/panel/index.d.ts +0 -5
  154. package/declaration/index.d.ts +0 -16
  155. package/declaration/reactive/index.d.ts +0 -25
  156. package/declaration/renderer/Renderer.d.ts +0 -60
  157. package/declaration/type/event.d.ts +0 -88
  158. package/declaration/type/external.d.ts +0 -31
  159. package/jsconfig.json +0 -5
  160. package/jsdoc-to-mdx.json +0 -7
  161. package/rollup.config.demo.js +0 -24
  162. package/rollup.config.dev.js +0 -12
  163. package/rollup.config.js +0 -57
  164. package/src/const/error.ts +0 -64
  165. package/src/const/external.ts +0 -138
  166. package/src/type/event.ts +0 -315
  167. package/src/type/external.ts +0 -78
  168. package/tsconfig.declaration.json +0 -17
  169. package/tsconfig.eslint.json +0 -10
  170. package/tsconfig.json +0 -23
  171. package/{declaration → dist}/camera/index.d.ts +0 -0
  172. package/{declaration → dist}/camera/mode/index.d.ts +2 -2
  173. package/{declaration → dist}/cfc/getRenderingPanels.d.ts +0 -0
  174. package/{declaration → dist}/cfc/index.d.ts +3 -3
  175. package/{declaration → dist}/cfc/sync.d.ts +0 -0
  176. package/{declaration → dist}/control/index.d.ts +7 -7
  177. package/{declaration → dist}/core/ResizeWatcher.d.ts +0 -0
  178. package/{declaration → dist}/core/panel/provider/ElementProvider.d.ts +0 -0
  179. package/{declaration → dist}/core/panel/provider/index.d.ts +0 -0
  180. package/{declaration → dist}/index.cjs.d.ts +0 -0
  181. package/{declaration → dist}/index.umd.d.ts +0 -0
  182. package/{declaration → dist}/renderer/index.d.ts +1 -1
  183. package/{declaration → dist}/renderer/strategy/VirtualRenderingStrategy.d.ts +1 -1
  184. package/{declaration → dist}/renderer/strategy/index.d.ts +1 -1
  185. /package/{declaration/type → dist/types}/internal.d.ts +0 -0
@@ -6,28 +6,23 @@ import { OnRelease } from "@egjs/axes";
6
6
  import { ComponentEvent } from "@egjs/component";
7
7
 
8
8
  import Panel from "../../core/panel/Panel";
9
- import { EVENTS } from "../../const/external";
9
+ import { EVENTS } from "../../event/names";
10
10
  import { getDirection } from "../../utils";
11
11
 
12
12
  import State, { STATE_TYPE } from "./State";
13
13
 
14
14
  /**
15
15
  * A state that activates when user's holding the Flicking area, but not moved a single pixel yet
16
- * @ko 사용자의 입력이 시작되었으나, 아직 움직이지는 않은 상태
17
16
  * @internal
18
17
  */
19
18
  class HoldingState extends State {
20
19
  /**
21
20
  * Whether user is clicking or touching
22
- * @ko 현재 사용자가 클릭/터치중인지 여부
23
- * @type {true}
24
21
  * @readonly
25
22
  */
26
23
  public readonly holding = true;
27
24
  /**
28
25
  * Whether Flicking's animating
29
- * @ko 현재 애니메이션 동작 여부
30
- * @type {false}
31
26
  * @readonly
32
27
  */
33
28
  public readonly animating = false;
@@ -43,9 +38,7 @@ class HoldingState extends State {
43
38
  return;
44
39
  }
45
40
 
46
- const offset = flicking.horizontal
47
- ? inputEvent.offsetX
48
- : inputEvent.offsetY;
41
+ const offset = flicking.horizontal ? inputEvent.offsetX : inputEvent.offsetY;
49
42
 
50
43
  const moveStartEvent = new ComponentEvent(EVENTS.MOVE_START, {
51
44
  isTrusted: axesEvent.isTrusted,
@@ -128,12 +121,14 @@ class HoldingState extends State {
128
121
  const cameraPosition = flicking.camera.position;
129
122
  const clickedPanelPosition = clickedPanel.position;
130
123
 
131
- flicking.trigger(new ComponentEvent(EVENTS.SELECT, {
132
- index: clickedPanel.index,
133
- panel: clickedPanel,
134
- // Direction to the clicked panel
135
- direction: getDirection(cameraPosition, clickedPanelPosition)
136
- }));
124
+ flicking.trigger(
125
+ new ComponentEvent(EVENTS.SELECT, {
126
+ index: clickedPanel.index,
127
+ panel: clickedPanel,
128
+ // Direction to the clicked panel
129
+ direction: getDirection(cameraPosition, clickedPanelPosition)
130
+ })
131
+ );
137
132
  }
138
133
  }
139
134
  }
@@ -4,28 +4,23 @@
4
4
  */
5
5
  import { ComponentEvent } from "@egjs/component";
6
6
 
7
- import { EVENTS } from "../../const/external";
7
+ import { EVENTS } from "../../event/names";
8
8
  import { getDirection } from "../../utils";
9
9
 
10
10
  import State, { STATE_TYPE } from "./State";
11
11
 
12
12
  /**
13
13
  * A default state when there's no user input and no animation's playing
14
- * @ko 사용자의 입력이 없고, 애니메이션이 동작하고있지 않은 기본 상태
15
14
  * @internal
16
15
  */
17
16
  class IdleState extends State {
18
17
  /**
19
18
  * Whether user is clicking or touching
20
- * @ko 현재 사용자가 클릭/터치중인지 여부
21
- * @type {false}
22
19
  * @readonly
23
20
  */
24
21
  public readonly holding = false;
25
22
  /**
26
23
  * Whether Flicking's animating
27
- * @ko 현재 애니메이션 동작 여부
28
- * @type {false}
29
24
  * @readonly
30
25
  */
31
26
  public readonly animating = false;
@@ -5,11 +5,10 @@
5
5
  /* eslint-disable @typescript-eslint/no-unused-vars */
6
6
  import { OnAnimationEnd, OnChange, OnFinish, OnHold, OnRelease } from "@egjs/axes";
7
7
  import { ComponentEvent } from "@egjs/component";
8
-
9
- import Flicking from "../../Flicking";
8
+ import * as AXES from "../../constants/internal";
10
9
  import Panel from "../../core/panel/Panel";
11
- import { EVENTS } from "../../const/external";
12
- import * as AXES from "../../const/axes";
10
+ import { EVENTS } from "../../event/names";
11
+ import Flicking from "../../Flicking";
13
12
  import { circulatePosition, getDirection } from "../../utils";
14
13
 
15
14
  export enum STATE_TYPE {
@@ -20,23 +19,31 @@ export enum STATE_TYPE {
20
19
  DISABLED
21
20
  }
22
21
 
22
+ /**
23
+ * Event context for State event handlers
24
+ * @internal
25
+ */
26
+ export interface StateContext<T> {
27
+ /** An instance of Flicking */
28
+ flicking: Flicking;
29
+ /** An Axes event */
30
+ axesEvent: T;
31
+ /** A function for changing current state to other state */
32
+ transitTo: (nextState: STATE_TYPE) => State;
33
+ }
34
+
23
35
  /**
24
36
  * A component that shows the current status of the user input or the animation
25
- * @ko 현재 사용자 입력 또는 애니메이션 상태를 나타내는 컴포넌트
26
37
  * @internal
27
38
  */
28
39
  abstract class State {
29
40
  /**
30
41
  * Whether user is clicking or touching
31
- * @ko 현재 사용자가 클릭/터치중인지 여부
32
- * @type {boolean}
33
42
  * @readonly
34
43
  */
35
44
  public abstract readonly holding: boolean;
36
45
  /**
37
46
  * Whether Flicking's animating
38
- * @ko 현재 애니메이션 동작 여부
39
- * @type {boolean}
40
47
  * @readonly
41
48
  */
42
49
  public abstract readonly animating: boolean;
@@ -46,27 +53,27 @@ abstract class State {
46
53
 
47
54
  /**
48
55
  * A sum of delta values of change events from the last hold event of Axes
49
- * @ko 이전 hold이벤트부터 change에 의해 발생한 이동 delta값의 합산
50
- * @type {number}
51
56
  * @readonly
52
57
  */
53
- public get delta() { return this._delta; }
58
+ public get delta(): number {
59
+ return this._delta;
60
+ }
54
61
 
55
62
  /**
56
- * A panel to set as {@link Control#activePanel} after the animation is finished
57
- * @ko 애니메이션 종료시 {@link Control#activePanel}로 설정할 패널
58
- * @type {number}
63
+ * A panel to set as {@link Control.activePanel} after the animation is finished
59
64
  * @readonly
60
65
  */
61
- public get targetPanel() { return this._targetPanel; }
66
+ public get targetPanel(): Panel | null {
67
+ return this._targetPanel;
68
+ }
62
69
 
63
- public set targetPanel(val: Panel | null) { this._targetPanel = val; }
70
+ public set targetPanel(val: Panel | null) {
71
+ this._targetPanel = val;
72
+ }
64
73
 
65
74
  /**
66
75
  * An callback which is called when state has changed to this state
67
- * @ko 현재 상태로 돌입했을때 호출되는 콜백 함수
68
- * @param {State} prevState An previous state<ko>이전 상태값</ko>
69
- * @return {void}
76
+ * @param prevState - An previous state
70
77
  */
71
78
  public onEnter(prevState: State): void {
72
79
  this._delta = prevState._delta;
@@ -74,95 +81,49 @@ abstract class State {
74
81
  }
75
82
 
76
83
  /**
77
- * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:hold hold} event
78
- * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:hold hold} 이벤트 핸들러
79
- * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
80
- * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
81
- * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:hold hold} event of Axes
82
- * <ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:hold hold} 이벤트</ko>
83
- * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
84
- * @return {void}
84
+ * An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-hold | hold} event
85
+ * @param ctx - {@link StateContext}
85
86
  */
86
- public onHold(ctx: {
87
- flicking: Flicking;
88
- axesEvent: OnHold;
89
- transitTo: (nextState: STATE_TYPE) => State;
90
- }): void {
87
+ public onHold(ctx: StateContext<OnHold>): void {
91
88
  // DO NOTHING
92
89
  }
93
90
 
94
91
  /**
95
- * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:change change} event
96
- * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:change change} 이벤트 핸들러
97
- * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
98
- * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
99
- * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:change change} event of Axes
100
- * <ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:change change} 이벤트</ko>
101
- * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
102
- * @return {void}
92
+ * An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-change | change} event
93
+ * @param ctx - {@link StateContext}
103
94
  */
104
- public onChange(ctx: {
105
- flicking: Flicking;
106
- axesEvent: OnChange;
107
- transitTo: (nextState: STATE_TYPE) => State;
108
- }): void {
95
+ public onChange(ctx: StateContext<OnChange>): void {
109
96
  // DO NOTHING
110
97
  }
111
98
 
112
99
  /**
113
- * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event
114
- * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트 핸들러
115
- * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
116
- * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
117
- * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event of Axes
118
- * <ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트</ko>
119
- * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
120
- * @return {void}
100
+ * An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-release | release} event
101
+ * @param ctx - {@link StateContext}
121
102
  */
122
- public onRelease(ctx: {
123
- flicking: Flicking;
124
- axesEvent: OnRelease;
125
- transitTo: (nextState: STATE_TYPE) => State;
126
- }): void {
103
+ public onRelease(ctx: StateContext<OnRelease>): void {
127
104
  // DO NOTHING
128
105
  }
129
106
 
130
107
  /**
131
- * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:animationEnd animationEnd} event
132
- * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:animationEnd animationEnd} 이벤트 핸들러
133
- * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
134
- * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
135
- * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:animationEnd animationEnd} event of Axes
136
- * <ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:animationEnd animationEnd} 이벤트</ko>
137
- * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
138
- * @return {void}
108
+ * An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-animationEnd | animationEnd} event
109
+ * @param ctx - {@link StateContext}
139
110
  */
140
- public onAnimationEnd(ctx: {
141
- flicking: Flicking;
142
- axesEvent: OnAnimationEnd;
143
- transitTo: (nextState: STATE_TYPE) => State;
144
- }): void {
111
+ public onAnimationEnd(ctx: StateContext<OnAnimationEnd>): void {
145
112
  // DO NOTHING
146
113
  }
147
114
 
148
115
  /**
149
- * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:finish finish} event
150
- * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:finish finish} 이벤트 핸들러
151
- * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
152
- * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
153
- * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:finish finish} event of Axes<ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:finish finish} 이벤트</ko>
154
- * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
155
- * @return {void}
116
+ * An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-finish | finish} event
117
+ * @param ctx - {@link StateContext}
156
118
  */
157
- public onFinish(ctx: {
158
- flicking: Flicking;
159
- axesEvent: OnFinish;
160
- transitTo: (nextState: STATE_TYPE) => State;
161
- }): void {
119
+ public onFinish(ctx: StateContext<OnFinish>): void {
162
120
  // DO NOTHING
163
121
  }
164
122
 
165
- protected _moveToChangedPosition(ctx: Parameters<State["onChange"]>[0]): void {
123
+ /**
124
+ * @internal
125
+ */
126
+ protected _moveToChangedPosition(ctx: StateContext<OnChange>): void {
166
127
  const { flicking, axesEvent, transitTo } = ctx;
167
128
  const delta = axesEvent.delta[AXES.POSITION_KEY];
168
129
 
@@ -4,9 +4,20 @@
4
4
  */
5
5
  import Panel from "./panel/Panel";
6
6
 
7
+ /**
8
+ * Options for creating an AnchorPoint
9
+ */
10
+ export interface AnchorPointOptions {
11
+ /** Index of AnchorPoint */
12
+ index: number;
13
+ /** Position of AnchorPoint */
14
+ position: number;
15
+ /** A {@link Panel} instance AnchorPoint is referencing to */
16
+ panel: Panel;
17
+ }
18
+
7
19
  /**
8
20
  * A data component that has actual position where the camera should be stopped at
9
- * @ko 카메라가 정지해야하는 실제 위치를 담고 있는 데이터 컴포넌트
10
21
  */
11
22
  class AnchorPoint {
12
23
  private _index: number;
@@ -15,41 +26,32 @@ class AnchorPoint {
15
26
 
16
27
  /**
17
28
  * Index of AnchorPoint
18
- * @ko AnchorPoint의 인덱스
19
- * @type {number}
20
29
  * @readonly
21
30
  */
22
- public get index() { return this._index; }
31
+ public get index(): number {
32
+ return this._index;
33
+ }
23
34
  /**
24
35
  * Position of AnchorPoint
25
- * @ko AnchorPoint의 좌표
26
- * @type {number}
27
36
  * @readonly
28
37
  */
29
- public get position() { return this._pos; }
38
+ public get position(): number {
39
+ return this._pos;
40
+ }
30
41
  /**
31
42
  * A {@link Panel} instance AnchorPoint is referencing to
32
- * @ko AnchorPoint가 참조하고 있는 {@link Panel}
33
- * @type {Panel}
34
43
  * @readonly
35
44
  */
36
- public get panel() { return this._panel; }
45
+ public get panel(): Panel {
46
+ return this._panel;
47
+ }
37
48
 
38
49
  /**
39
- * @param {object} options An options object<ko>옵션 객체</ko>
40
- * @param {number} [options.index] Index of AnchorPoint<ko>AnchorPoint의 인덱스</ko>
41
- * @param {number} [options.position] Position of AnchorPoint<ko>AnchorPoint의 좌표</ko>
42
- * @param {Panel} [options.panel] A {@link Panel} instance AnchorPoint is referencing to<ko>AnchorPoint가 참조하고 있는 {@link Panel}</ko>
50
+ * @param options - {@link AnchorPointOptions}
43
51
  */
44
- public constructor({
45
- index,
46
- position,
47
- panel
48
- }: {
49
- index: number;
50
- position: number;
51
- panel: Panel;
52
- }) {
52
+ public constructor(options: AnchorPointOptions) {
53
+ const { index, position, panel } = options;
54
+
53
55
  this._index = index;
54
56
  this._pos = position;
55
57
  this._panel = panel;
@@ -2,12 +2,12 @@
2
2
  * Copyright (c) 2015 NAVER Corp.
3
3
  * egjs projects are licensed under the MIT license
4
4
  */
5
- import { getElementSize, getStyle } from "../utils";
5
+
6
6
  import Flicking from "../Flicking";
7
+ import { getElementSize, getStyle } from "../utils";
7
8
 
8
9
  /**
9
10
  * A component that detects size change and trigger resize method when the autoResize option is used
10
- * @ko autoResize 옵션을 사용할 때 크기 변화를 감지하고 Flicking의 resize를 호출하는 컴포넌트
11
11
  */
12
12
  class AutoResizer {
13
13
  private _flicking: Flicking;
@@ -157,10 +157,7 @@ class AutoResizer {
157
157
  })
158
158
  };
159
159
 
160
- if (
161
- beforeSize.height === afterSize.height &&
162
- beforeSize.width === afterSize.width
163
- ) {
160
+ if (beforeSize.height === afterSize.height && beforeSize.width === afterSize.width) {
164
161
  return;
165
162
  }
166
163
  }
@@ -170,10 +167,7 @@ class AutoResizer {
170
167
  } else {
171
168
  if (this._maxResizeDebounceTimer <= 0) {
172
169
  if (maxResizeDebounce > 0 && maxResizeDebounce >= resizeDebounce) {
173
- this._maxResizeDebounceTimer = window.setTimeout(
174
- this._doScheduledResize,
175
- maxResizeDebounce
176
- );
170
+ this._maxResizeDebounceTimer = window.setTimeout(this._doScheduledResize, maxResizeDebounce);
177
171
  }
178
172
  }
179
173
 
@@ -182,10 +176,7 @@ class AutoResizer {
182
176
  this._resizeTimer = 0;
183
177
  }
184
178
 
185
- this._resizeTimer = window.setTimeout(
186
- this._doScheduledResize,
187
- resizeDebounce
188
- );
179
+ this._resizeTimer = window.setTimeout(this._doScheduledResize, resizeDebounce);
189
180
  }
190
181
  };
191
182
 
@@ -203,7 +194,7 @@ class AutoResizer {
203
194
  private _skipFirstResize = (() => {
204
195
  let isFirstResize = true;
205
196
 
206
- return (entries) => {
197
+ return entries => {
207
198
  if (isFirstResize) {
208
199
  isFirstResize = false;
209
200
  return;
@@ -20,7 +20,7 @@ class ResizeWatcher {
20
20
  private _rect = { width: 0, height: 0 };
21
21
  private _resizeTimer = 0;
22
22
  private _maxResizeDebounceTimer = 0;
23
- private _emitter: Component<{ resize: void }>;
23
+ private _emitter: Component<{ resize: undefined }>;
24
24
  private _observer: ResizeObserver | null;
25
25
  private _options!: Required<ResizeWatherOptions>;
26
26
 
@@ -50,13 +50,17 @@ class ResizeWatcher {
50
50
  public resize() {
51
51
  const container = this._container;
52
52
 
53
- this.setRect(this._options.rectBox === "border-box" ? {
54
- width: container.offsetWidth,
55
- height: container.offsetHeight
56
- } : {
57
- width: container.clientWidth,
58
- height: container.clientHeight
59
- });
53
+ this.setRect(
54
+ this._options.rectBox === "border-box"
55
+ ? {
56
+ width: container.offsetWidth,
57
+ height: container.offsetHeight
58
+ }
59
+ : {
60
+ width: container.clientWidth,
61
+ height: container.clientHeight
62
+ }
63
+ );
60
64
  }
61
65
 
62
66
  public listen(callback: () => void) {
@@ -101,9 +105,10 @@ class ResizeWatcher {
101
105
  const rect = this._rect;
102
106
  const isWatchWidth = watchDirection === "box" || watchDirection === "width";
103
107
  const isWatchHeight = watchDirection === "box" || watchDirection === "height";
104
- const isResize = !watchDirection
105
- || (isWatchWidth && prevRect.width !== rect.width)
106
- || (isWatchHeight && prevRect.height !== rect.height);
108
+ const isResize =
109
+ !watchDirection ||
110
+ (isWatchWidth && prevRect.width !== rect.width) ||
111
+ (isWatchHeight && prevRect.height !== rect.height);
107
112
 
108
113
  if (isResize) {
109
114
  this._emitter.trigger("resize");
@@ -111,11 +116,7 @@ class ResizeWatcher {
111
116
  };
112
117
 
113
118
  private _scheduleResize = () => {
114
- const {
115
- resizeDebounce,
116
- maxResizeDebounce
117
- } = this._options;
118
-
119
+ const { resizeDebounce, maxResizeDebounce } = this._options;
119
120
 
120
121
  if (!this._maxResizeDebounceTimer && maxResizeDebounce >= resizeDebounce) {
121
122
  this._maxResizeDebounceTimer = window.setTimeout(this._onResize, maxResizeDebounce);
@@ -3,11 +3,22 @@
3
3
  * egjs projects are licensed under the MIT license
4
4
  */
5
5
  import Flicking from "../Flicking";
6
+ import { SetSizeParams } from "../types/params";
6
7
  import { getElementSize, getStyle, isString } from "../utils";
7
8
 
9
+ export interface ViewportPadding {
10
+ /** CSS `padding-left` */
11
+ left: number;
12
+ /** CSS `padding-right` */
13
+ right: number;
14
+ /** CSS `padding-top` */
15
+ top: number;
16
+ /** CSS `padding-bottom` */
17
+ bottom: number;
18
+ }
19
+
8
20
  /**
9
21
  * A component that manages viewport size
10
- * @ko 뷰포트 크기 정보를 담당하는 컴포넌트
11
22
  */
12
23
  class Viewport {
13
24
  private _flicking: Flicking;
@@ -15,49 +26,41 @@ class Viewport {
15
26
  private _width: number;
16
27
  private _height: number;
17
28
  private _isBorderBoxSizing: boolean;
18
- private _padding: {
19
- left: number;
20
- right: number;
21
- top: number;
22
- bottom: number;
23
- };
29
+ private _padding: ViewportPadding;
24
30
 
25
31
  /**
26
32
  * A viewport(root) element
27
- * @ko 뷰포트(root) 엘리먼트
28
- * @type {HTMLElement}
29
33
  * @readonly
30
34
  */
31
- public get element() { return this._el; }
35
+ public get element(): HTMLElement {
36
+ return this._el;
37
+ }
32
38
 
33
39
  /**
34
40
  * Viewport width, without paddings
35
- * @ko 뷰포트 너비
36
- * @type {number}
37
41
  * @readonly
38
42
  */
39
- public get width() { return this._width - this._padding.left - this._padding.right; }
43
+ public get width(): number {
44
+ return this._width - this._padding.left - this._padding.right;
45
+ }
40
46
  /**
41
47
  * Viewport height, without paddings
42
- * @ko 뷰포트 높이
43
- * @type {number}
44
48
  * @readonly
45
49
  */
46
- public get height() { return this._height - this._padding.top - this._padding.bottom; }
50
+ public get height(): number {
51
+ return this._height - this._padding.top - this._padding.bottom;
52
+ }
47
53
  /**
48
54
  * Viewport paddings
49
- * @ko 뷰포트 CSS padding 값
50
- * @type {object}
51
- * @property {number} left CSS `padding-left`
52
- * @property {number} right CSS `padding-right`
53
- * @property {number} top CSS `padding-top`
54
- * @property {number} bottom CSS `padding-bottom`
55
55
  * @readonly
56
56
  */
57
- public get padding() { return this._padding; }
57
+ public get padding(): ViewportPadding {
58
+ return this._padding;
59
+ }
58
60
 
59
61
  /**
60
- * @param el A viewport element<ko>뷰포트 엘리먼트</ko>
62
+ * @param flicking - Flicking instance
63
+ * @param el - A viewport element
61
64
  */
62
65
  public constructor(flicking: Flicking, el: HTMLElement) {
63
66
  this._flicking = flicking;
@@ -75,20 +78,13 @@ class Viewport {
75
78
 
76
79
  /**
77
80
  * Change viewport's size.
81
+ * @remarks
78
82
  * This will change the actual size of `.flicking-viewport` element by changing its CSS width/height property
79
- * @ko 뷰포트 크기를 변경합니다.
80
- * `.flicking-viewport` 엘리먼트에 해당 크기의 CSS width/height를 적용합니다
81
- * @param {object} [size] New viewport size<ko>새 뷰포트 크기</ko>
82
- * @param {number|string} [size.width] CSS string or number(in px)<ko>CSS 문자열 또는 숫자(px)</ko>
83
- * @param {number|string} [size.height] CSS string or number(in px)<ko>CSS 문자열 또는 숫자(px)</ko>
83
+ * @param size - {@link SetSizeParams}
84
84
  */
85
- public setSize({
86
- width,
87
- height
88
- }: Partial<{
89
- width: number | string;
90
- height: number | string;
91
- }>) {
85
+ public setSize(size: SetSizeParams) {
86
+ const { width, height } = size;
87
+
92
88
  const el = this._el;
93
89
  const padding = this._padding;
94
90
  const isBorderBoxSizing = this._isBorderBoxSizing;
@@ -97,9 +93,7 @@ class Viewport {
97
93
  if (isString(width)) {
98
94
  el.style.width = width;
99
95
  } else {
100
- const newWidth = isBorderBoxSizing
101
- ? width + padding.left + padding.right
102
- : width;
96
+ const newWidth = isBorderBoxSizing ? width + padding.left + padding.right : width;
103
97
  el.style.width = `${newWidth}px`;
104
98
  }
105
99
  }
@@ -107,9 +101,7 @@ class Viewport {
107
101
  if (isString(height)) {
108
102
  el.style.height = height;
109
103
  } else {
110
- const newHeight = isBorderBoxSizing
111
- ? height + padding.top + padding.bottom
112
- : height;
104
+ const newHeight = isBorderBoxSizing ? height + padding.top + padding.bottom : height;
113
105
  el.style.height = `${newHeight}px`;
114
106
  }
115
107
  }
@@ -118,14 +110,11 @@ class Viewport {
118
110
 
119
111
  /**
120
112
  * Update width/height to the current viewport element's size
121
- * @ko 현재 뷰포트 엘리먼트의 크기로 너비/높이를 업데이트합니다
122
113
  */
123
114
  public resize() {
124
115
  const el = this._el;
125
116
  const elStyle = getStyle(el);
126
- const {
127
- useFractionalSize
128
- } = this._flicking;
117
+ const { useFractionalSize } = this._flicking;
129
118
 
130
119
  this._width = getElementSize({
131
120
  el,