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