@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.
- 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 +5559 -7791
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +5637 -7699
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +6722 -8893
- 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 -14086
- 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 +1051 -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 -4
- 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 +170 -115
- package/src/renderer/VanillaRenderer.ts +12 -9
- 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/core/panel/Panel.ts
CHANGED
|
@@ -2,23 +2,43 @@
|
|
|
2
2
|
* Copyright (c) 2015 NAVER Corp.
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
+
|
|
6
|
+
import { ALIGN, DIRECTION } from "../../constants/values";
|
|
5
7
|
import Flicking from "../../Flicking";
|
|
8
|
+
import { LiteralUnion, ValueOf } from "../../types/internal";
|
|
9
|
+
import { SetSizeParams } from "../../types/params";
|
|
6
10
|
import { getElementSize, getProgress, getStyle, parseAlign, setSize } from "../../utils";
|
|
7
|
-
import { ALIGN, DIRECTION } from "../../const/external";
|
|
8
|
-
import { LiteralUnion, ValueOf } from "../../type/internal";
|
|
9
11
|
|
|
10
12
|
import ElementProvider from "./provider/ElementProvider";
|
|
11
13
|
|
|
12
14
|
export interface PanelOptions {
|
|
15
|
+
/** An initial index of the panel */
|
|
13
16
|
index: number;
|
|
17
|
+
/** An initial {@link Flicking.align | align} value of the panel */
|
|
14
18
|
align: LiteralUnion<ValueOf<typeof ALIGN>> | number;
|
|
19
|
+
/** The Flicking instance that this panel belongs to */
|
|
15
20
|
flicking: Flicking;
|
|
21
|
+
/** A provider instance that returns the actual html element */
|
|
16
22
|
elementProvider: ElementProvider;
|
|
17
23
|
}
|
|
18
24
|
|
|
25
|
+
export interface PanelMarginInfo {
|
|
26
|
+
/** CSS `margin-left` when the {@link Flicking.horizontal | horizontal} is `true`, and `margin-top` else */
|
|
27
|
+
prev: number;
|
|
28
|
+
/** CSS `margin-right` when the {@link Flicking.horizontal | horizontal} is `true`, and `margin-bottom` else */
|
|
29
|
+
next: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface PanelBoundingBoxRange {
|
|
33
|
+
/** Bounding box's left({@link Flicking.horizontal | horizontal}: true) / top({@link Flicking.horizontal | horizontal}: false) */
|
|
34
|
+
min: number;
|
|
35
|
+
/** Bounding box's right({@link Flicking.horizontal | horizontal}: true) / bottom({@link Flicking.horizontal | horizontal}: false) */
|
|
36
|
+
max: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
19
39
|
/**
|
|
20
40
|
* A slide data component that holds information of a single HTMLElement
|
|
21
|
-
* @
|
|
41
|
+
* @public
|
|
22
42
|
*/
|
|
23
43
|
class Panel {
|
|
24
44
|
// Internal States
|
|
@@ -28,7 +48,7 @@ class Panel {
|
|
|
28
48
|
protected _pos: number;
|
|
29
49
|
protected _size: number;
|
|
30
50
|
protected _height: number;
|
|
31
|
-
protected _margin:
|
|
51
|
+
protected _margin: PanelMarginInfo;
|
|
32
52
|
protected _alignPos: number; // Actual align pos
|
|
33
53
|
protected _rendered: boolean;
|
|
34
54
|
protected _removed: boolean;
|
|
@@ -43,124 +63,118 @@ class Panel {
|
|
|
43
63
|
// Internal States Getter
|
|
44
64
|
/**
|
|
45
65
|
* `HTMLElement` that panel's referencing
|
|
46
|
-
* @ko 패널이 참조하고 있는 `HTMLElement`
|
|
47
|
-
* @type {HTMLElement}
|
|
48
66
|
* @readonly
|
|
49
67
|
*/
|
|
50
|
-
public get element() {
|
|
68
|
+
public get element(): HTMLElement {
|
|
69
|
+
return this._elProvider.element;
|
|
70
|
+
}
|
|
51
71
|
/**
|
|
52
72
|
* @internal
|
|
53
73
|
* @readonly
|
|
54
74
|
*/
|
|
55
|
-
public get elementProvider() {
|
|
75
|
+
public get elementProvider(): ElementProvider {
|
|
76
|
+
return this._elProvider;
|
|
77
|
+
}
|
|
56
78
|
/**
|
|
57
79
|
* Index of the panel
|
|
58
|
-
* @ko 패널의 인덱스
|
|
59
|
-
* @type {number}
|
|
60
80
|
* @readonly
|
|
61
81
|
*/
|
|
62
|
-
public get index() {
|
|
82
|
+
public get index(): number {
|
|
83
|
+
return this._index;
|
|
84
|
+
}
|
|
63
85
|
/**
|
|
64
|
-
* Position of the panel, including {@link Panel
|
|
65
|
-
* @ko 패널의 현재 좌표, {@link Panel#alignPosition alignPosition}을 포함하고 있습니다
|
|
66
|
-
* @type {number}
|
|
86
|
+
* Position of the panel, including {@link Panel.alignPosition | alignPosition}
|
|
67
87
|
* @readonly
|
|
68
88
|
*/
|
|
69
|
-
public get position() {
|
|
89
|
+
public get position(): number {
|
|
90
|
+
return this._pos + this._alignPos;
|
|
91
|
+
}
|
|
70
92
|
/**
|
|
71
93
|
* Cached size of the panel element
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
74
|
-
* 이 값은 {@link Flicking#horizontal horizontal}이 `true`일 경우 {@link Panel#element element}의 `offsetWidth`와 동일하고, `false`일 경우 `offsetHeight`와 동일합니다
|
|
75
|
-
* @type {number}
|
|
94
|
+
* @remarks
|
|
95
|
+
* This is equal to {@link Panel.element | element}'s `offsetWidth` if {@link Flicking.horizontal | horizontal} is `true`, and `offsetHeight` else
|
|
76
96
|
* @readonly
|
|
77
97
|
*/
|
|
78
|
-
public get size() {
|
|
98
|
+
public get size(): number {
|
|
99
|
+
return this._size;
|
|
100
|
+
}
|
|
79
101
|
/**
|
|
80
102
|
* Panel's size including CSS `margin`
|
|
81
|
-
*
|
|
82
|
-
* @
|
|
83
|
-
* 이 값은 {@link Flicking#horizontal horizontal}이 `true`일 경우 margin left/right을 포함하고, `false`일 경우 margin top/bottom을 포함합니다
|
|
84
|
-
* @type {number}
|
|
103
|
+
* @remarks
|
|
104
|
+
* This value includes {@link Panel.element | element}'s margin left/right if {@link Flicking.horizontal | horizontal} is `true`, and margin top/bottom else
|
|
85
105
|
* @readonly
|
|
86
106
|
*/
|
|
87
|
-
public get sizeIncludingMargin() {
|
|
107
|
+
public get sizeIncludingMargin(): number {
|
|
108
|
+
return this._size + this._margin.prev + this._margin.next;
|
|
109
|
+
}
|
|
88
110
|
/**
|
|
89
111
|
* Height of the panel element
|
|
90
|
-
* @ko 패널 엘리먼트의 높이
|
|
91
|
-
* @type {number}
|
|
92
112
|
* @readonly
|
|
93
113
|
*/
|
|
94
|
-
public get height() {
|
|
114
|
+
public get height(): number {
|
|
115
|
+
return this._height;
|
|
116
|
+
}
|
|
95
117
|
/**
|
|
96
118
|
* Cached CSS `margin` value of the panel element
|
|
97
|
-
* @ko 패널 엘리먼트의 CSS `margin` 값
|
|
98
|
-
* @type {object}
|
|
99
|
-
* @property {number} prev CSS `margin-left` when the {@link Flicking#horizontal horizontal} is `true`, and `margin-top` else
|
|
100
|
-
* <ko>{@link Flicking#horizontal horizontal}이 `true`일 경우 `margin-left`, `false`일 경우 `margin-top`에 해당하는 값</ko>
|
|
101
|
-
* @property {number} next CSS `margin-right` when the {@link Flicking#horizontal horizontal} is `true`, and `margin-bottom` else
|
|
102
|
-
* <ko>{@link Flicking#horizontal horizontal}이 `true`일 경우 `margin-right`, `false`일 경우 `margin-bottom`에 해당하는 값</ko>
|
|
103
119
|
* @readonly
|
|
104
120
|
*/
|
|
105
|
-
public get margin() {
|
|
121
|
+
public get margin(): PanelMarginInfo {
|
|
122
|
+
return this._margin;
|
|
123
|
+
}
|
|
106
124
|
/**
|
|
107
|
-
* Align position inside the panel where {@link Camera}'s {@link Camera
|
|
108
|
-
* @ko 패널의 정렬 기준 위치. {@link Camera}의 뷰포트 내에서의 {@link Camera#alignPosition alignPosition}이 위치해야 하는 곳입니다
|
|
109
|
-
* @type {number}
|
|
125
|
+
* Align position inside the panel where {@link Camera}'s {@link Camera.alignPosition | alignPosition} inside viewport should be located at
|
|
110
126
|
* @readonly
|
|
111
127
|
*/
|
|
112
|
-
public get alignPosition() {
|
|
128
|
+
public get alignPosition(): number {
|
|
129
|
+
return this._alignPos;
|
|
130
|
+
}
|
|
113
131
|
/**
|
|
114
|
-
* A value indicating whether the panel's {@link Flicking
|
|
115
|
-
* @ko 패널이 {@link Flicking#remove remove}되었는지 여부를 나타내는 값
|
|
116
|
-
* @type {boolean}
|
|
132
|
+
* A value indicating whether the panel's {@link Flicking.remove | remove}d
|
|
117
133
|
* @readonly
|
|
118
134
|
*/
|
|
119
|
-
public get removed() {
|
|
135
|
+
public get removed(): boolean {
|
|
136
|
+
return this._removed;
|
|
137
|
+
}
|
|
120
138
|
/**
|
|
121
139
|
* A value indicating whether the panel's element is being rendered on the screen
|
|
122
|
-
* @ko 패널의 엘리먼트가 화면상에 렌더링되고있는지 여부를 나타내는 값
|
|
123
|
-
* @type {boolean}
|
|
124
140
|
* @readonly
|
|
125
141
|
*/
|
|
126
|
-
public get rendered() {
|
|
142
|
+
public get rendered(): boolean {
|
|
143
|
+
return this._rendered;
|
|
144
|
+
}
|
|
127
145
|
/**
|
|
128
146
|
* A value indicating whether the panel's image/video is not loaded and waiting for resize
|
|
129
|
-
* @ko 패널 내부의 이미지/비디오가 아직 로드되지 않아 {@link Panel#resize resize}될 것인지를 나타내는 값
|
|
130
|
-
* @type {boolean}
|
|
131
147
|
* @readonly
|
|
132
148
|
*/
|
|
133
|
-
public get loading() {
|
|
149
|
+
public get loading(): boolean {
|
|
150
|
+
return this._loading;
|
|
151
|
+
}
|
|
134
152
|
/**
|
|
135
153
|
* Panel element's range of the bounding box
|
|
136
|
-
* @ko 패널 엘리먼트의 Bounding box 범위
|
|
137
|
-
* @type {object}
|
|
138
|
-
* @property {number} [min] Bounding box's left({@link Flicking#horizontal horizontal}: true) / top({@link Flicking#horizontal horizontal}: false)
|
|
139
|
-
* @property {number} [max] Bounding box's right({@link Flicking#horizontal horizontal}: true) / bottom({@link Flicking#horizontal horizontal}: false)
|
|
140
154
|
* @readonly
|
|
141
155
|
*/
|
|
142
|
-
public get range()
|
|
156
|
+
public get range(): PanelBoundingBoxRange {
|
|
157
|
+
return { min: this._pos, max: this._pos + this._size };
|
|
158
|
+
}
|
|
143
159
|
/**
|
|
144
160
|
* A value indicating whether the panel's position is toggled by circular behavior
|
|
145
|
-
* @ko 패널의 위치가 circular 동작에 의해 토글되었는지 여부를 나타내는 값
|
|
146
|
-
* @type {boolean}
|
|
147
161
|
* @readonly
|
|
148
162
|
*/
|
|
149
|
-
public get toggled() {
|
|
163
|
+
public get toggled(): boolean {
|
|
164
|
+
return this._toggled;
|
|
165
|
+
}
|
|
150
166
|
/**
|
|
151
167
|
* A direction where the panel's position is toggled
|
|
152
|
-
* @ko 패널의 위치가 circular 동작에 의해 토글되는 방향
|
|
153
|
-
* @type {DIRECTION}
|
|
154
168
|
* @readonly
|
|
155
169
|
*/
|
|
156
|
-
public get toggleDirection()
|
|
170
|
+
public get toggleDirection(): ValueOf<typeof DIRECTION> {
|
|
171
|
+
return this._toggleDirection;
|
|
172
|
+
}
|
|
157
173
|
/**
|
|
158
|
-
* Actual position offset determined by {@link Panel
|
|
159
|
-
* @ko {@link Panel#order}에 의한 실제 위치 변경값
|
|
160
|
-
* @type {number}
|
|
174
|
+
* Actual position offset determined by {@link Panel.order}
|
|
161
175
|
* @readonly
|
|
162
176
|
*/
|
|
163
|
-
public get offset() {
|
|
177
|
+
public get offset(): number {
|
|
164
178
|
const toggleDirection = this._toggleDirection;
|
|
165
179
|
const cameraRangeDiff = this._flicking.camera.rangeDiff;
|
|
166
180
|
|
|
@@ -173,11 +187,9 @@ class Panel {
|
|
|
173
187
|
|
|
174
188
|
/**
|
|
175
189
|
* Progress of movement between previous or next panel relative to current panel
|
|
176
|
-
* @ko 이 패널로부터 이전/다음 패널으로의 이동 진행률
|
|
177
|
-
* @type {number}
|
|
178
190
|
* @readonly
|
|
179
191
|
*/
|
|
180
|
-
public get progress() {
|
|
192
|
+
public get progress(): number {
|
|
181
193
|
const flicking = this._flicking;
|
|
182
194
|
|
|
183
195
|
return this.index - flicking.camera.progress;
|
|
@@ -185,11 +197,9 @@ class Panel {
|
|
|
185
197
|
|
|
186
198
|
/**
|
|
187
199
|
* Progress of movement between points that panel is completely invisible outside of viewport(prev direction: -1, selected point: 0, next direction: 1)
|
|
188
|
-
* @ko 현재 패널이 뷰포트 영역 밖으로 완전히 사라지는 지점을 기준으로 하는 진행도(prev방향: -1, 선택 지점: 0, next방향: 1)
|
|
189
|
-
* @type {number}
|
|
190
200
|
* @readonly
|
|
191
201
|
*/
|
|
192
|
-
public get outsetProgress() {
|
|
202
|
+
public get outsetProgress(): number {
|
|
193
203
|
const position = this.position + this.offset;
|
|
194
204
|
const alignPosition = this._alignPos;
|
|
195
205
|
const camera = this._flicking.camera;
|
|
@@ -212,11 +222,9 @@ class Panel {
|
|
|
212
222
|
|
|
213
223
|
/**
|
|
214
224
|
* Percentage of area where panel is visible in the viewport
|
|
215
|
-
* @ko 뷰포트 안에서 패널이 보이는 영역의 비율
|
|
216
|
-
* @type {number}
|
|
217
225
|
* @readonly
|
|
218
226
|
*/
|
|
219
|
-
public get visibleRatio() {
|
|
227
|
+
public get visibleRatio(): number {
|
|
220
228
|
const range = this.range;
|
|
221
229
|
const size = this._size;
|
|
222
230
|
const offset = this.offset;
|
|
@@ -243,15 +251,17 @@ class Panel {
|
|
|
243
251
|
return visibleSize / size;
|
|
244
252
|
}
|
|
245
253
|
|
|
246
|
-
public set loading(val: boolean) {
|
|
254
|
+
public set loading(val: boolean) {
|
|
255
|
+
this._loading = val;
|
|
256
|
+
}
|
|
247
257
|
|
|
248
258
|
// Options Getter
|
|
249
259
|
/**
|
|
250
|
-
* A value indicating where the {@link Panel
|
|
251
|
-
* @ko {@link Panel#alignPosition alignPosition}이 패널 내의 어디에 위치해야 하는지를 나타내는 값
|
|
252
|
-
* @type {Constants.ALIGN | string | number}
|
|
260
|
+
* A value indicating where the {@link Panel.alignPosition | alignPosition} should be located at inside the panel element
|
|
253
261
|
*/
|
|
254
|
-
public get align() {
|
|
262
|
+
public get align(): PanelOptions["align"] {
|
|
263
|
+
return this._align;
|
|
264
|
+
}
|
|
255
265
|
|
|
256
266
|
// Options Setter
|
|
257
267
|
public set align(val: PanelOptions["align"]) {
|
|
@@ -260,18 +270,12 @@ class Panel {
|
|
|
260
270
|
}
|
|
261
271
|
|
|
262
272
|
/**
|
|
263
|
-
*
|
|
264
|
-
* @param
|
|
265
|
-
* @param {Constants.ALIGN | string | number} [options.align] An initial {@link Flicking#align align} value of the panel<ko>패널의 초기 {@link Flicking#align align}값</ko>
|
|
266
|
-
* @param {Flicking} [options.flicking] A Flicking instance panel's referencing<ko>패널이 참조하는 {@link Flicking} 인스턴스</ko>
|
|
267
|
-
* @param {Flicking} [options.elementProvider] A provider instance that redirects elements<ko>실제 엘리먼트를 반환하는 엘리먼트 공급자의 인스턴스</ko>
|
|
273
|
+
* Creates a new Panel instance
|
|
274
|
+
* @param panelOptions - Options for creating the panel
|
|
268
275
|
*/
|
|
269
|
-
public constructor({
|
|
270
|
-
index,
|
|
271
|
-
|
|
272
|
-
flicking,
|
|
273
|
-
elementProvider
|
|
274
|
-
}: PanelOptions) {
|
|
276
|
+
public constructor(panelOptions: PanelOptions) {
|
|
277
|
+
const { index, align, flicking, elementProvider } = panelOptions;
|
|
278
|
+
|
|
275
279
|
this._index = index;
|
|
276
280
|
this._flicking = flicking;
|
|
277
281
|
this._elProvider = elementProvider;
|
|
@@ -285,8 +289,9 @@ class Panel {
|
|
|
285
289
|
}
|
|
286
290
|
|
|
287
291
|
/**
|
|
288
|
-
* Mark panel element to be appended on the camera element
|
|
289
292
|
* @internal
|
|
293
|
+
* @privateRemarks
|
|
294
|
+
* Marks this panel to be rendered on the camera element.
|
|
290
295
|
*/
|
|
291
296
|
public markForShow() {
|
|
292
297
|
this._rendered = true;
|
|
@@ -294,8 +299,9 @@ class Panel {
|
|
|
294
299
|
}
|
|
295
300
|
|
|
296
301
|
/**
|
|
297
|
-
* Mark panel element to be removed from the camera element
|
|
298
302
|
* @internal
|
|
303
|
+
* @privateRemarks
|
|
304
|
+
* Marks this panel to be hidden from the camera element.
|
|
299
305
|
*/
|
|
300
306
|
public markForHide() {
|
|
301
307
|
this._rendered = false;
|
|
@@ -304,22 +310,15 @@ class Panel {
|
|
|
304
310
|
|
|
305
311
|
/**
|
|
306
312
|
* Update size of the panel
|
|
307
|
-
* @
|
|
308
|
-
*
|
|
309
|
-
* @
|
|
310
|
-
* @
|
|
311
|
-
*/
|
|
312
|
-
public resize(cached?: {
|
|
313
|
-
size: number;
|
|
314
|
-
height?: number;
|
|
315
|
-
margin: { prev: number; next: number };
|
|
316
|
-
}): this {
|
|
313
|
+
* @remarks
|
|
314
|
+
* This method recalculates the panel's size, margin, and position based on the current DOM state.
|
|
315
|
+
* @param cached - Predefined cached size of the panel
|
|
316
|
+
* @returns The current instance for method chaining
|
|
317
|
+
*/
|
|
318
|
+
public resize(cached?: { size: number; height?: number; margin: { prev: number; next: number } }): this {
|
|
317
319
|
const el = this.element;
|
|
318
320
|
const flicking = this._flicking;
|
|
319
|
-
const {
|
|
320
|
-
horizontal,
|
|
321
|
-
useFractionalSize
|
|
322
|
-
} = flicking;
|
|
321
|
+
const { horizontal, useFractionalSize } = flicking;
|
|
323
322
|
|
|
324
323
|
if (!el) {
|
|
325
324
|
return this;
|
|
@@ -328,13 +327,15 @@ class Panel {
|
|
|
328
327
|
if (cached) {
|
|
329
328
|
this._size = cached.size;
|
|
330
329
|
this._margin = { ...cached.margin };
|
|
331
|
-
this._height =
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
330
|
+
this._height =
|
|
331
|
+
cached.height ??
|
|
332
|
+
getElementSize({
|
|
333
|
+
el,
|
|
334
|
+
horizontal: false,
|
|
335
|
+
useFractionalSize,
|
|
336
|
+
useOffset: true,
|
|
337
|
+
style: getStyle(el)
|
|
338
|
+
});
|
|
338
339
|
} else {
|
|
339
340
|
const elStyle = getStyle(el);
|
|
340
341
|
|
|
@@ -348,21 +349,22 @@ class Panel {
|
|
|
348
349
|
|
|
349
350
|
this._margin = horizontal
|
|
350
351
|
? {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
352
|
+
prev: parseFloat(elStyle.marginLeft || "0"),
|
|
353
|
+
next: parseFloat(elStyle.marginRight || "0")
|
|
354
|
+
}
|
|
355
|
+
: {
|
|
356
|
+
prev: parseFloat(elStyle.marginTop || "0"),
|
|
357
|
+
next: parseFloat(elStyle.marginBottom || "0")
|
|
358
|
+
};
|
|
357
359
|
|
|
358
360
|
this._height = horizontal
|
|
359
361
|
? getElementSize({
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
362
|
+
el,
|
|
363
|
+
horizontal: false,
|
|
364
|
+
useFractionalSize,
|
|
365
|
+
useOffset: true,
|
|
366
|
+
style: elStyle
|
|
367
|
+
})
|
|
366
368
|
: this._size;
|
|
367
369
|
}
|
|
368
370
|
|
|
@@ -373,37 +375,33 @@ class Panel {
|
|
|
373
375
|
}
|
|
374
376
|
|
|
375
377
|
/**
|
|
376
|
-
* Change panel's size
|
|
377
|
-
* @
|
|
378
|
-
*
|
|
379
|
-
* @param
|
|
380
|
-
* @
|
|
381
|
-
* @chainable
|
|
382
|
-
* @return {this}
|
|
378
|
+
* Change panel's size
|
|
379
|
+
* @remarks
|
|
380
|
+
* This will change the actual size of the panel element by changing its CSS width/height property.
|
|
381
|
+
* @param size - {@link SetSizeParams}
|
|
382
|
+
* @returns The current instance for method chaining
|
|
383
383
|
*/
|
|
384
|
-
public setSize(size:
|
|
385
|
-
width: number | string;
|
|
386
|
-
height: number | string;
|
|
387
|
-
}>): this {
|
|
384
|
+
public setSize(size: SetSizeParams): this {
|
|
388
385
|
setSize(this.element, size);
|
|
389
386
|
|
|
390
387
|
return this;
|
|
391
388
|
}
|
|
392
389
|
|
|
393
390
|
/**
|
|
394
|
-
* Check whether the given element is inside of this panel's {@link Panel
|
|
395
|
-
* @
|
|
396
|
-
*
|
|
397
|
-
* @
|
|
391
|
+
* Check whether the given element is inside of this panel's {@link Panel.element | element}
|
|
392
|
+
* @remarks
|
|
393
|
+
* This is useful for determining which panel contains a clicked element.
|
|
394
|
+
* @param element - The HTMLElement to check
|
|
395
|
+
* @returns A Boolean value indicating the element is inside of this panel {@link Panel.element | element}
|
|
398
396
|
*/
|
|
399
397
|
public contains(element: HTMLElement): boolean {
|
|
400
398
|
return !!this.element?.contains(element);
|
|
401
399
|
}
|
|
402
400
|
|
|
403
401
|
/**
|
|
404
|
-
* Reset internal state and set {@link Panel
|
|
405
|
-
* @
|
|
406
|
-
*
|
|
402
|
+
* Reset internal state and set {@link Panel.removed | removed} to `true`
|
|
403
|
+
* @remarks
|
|
404
|
+
* After calling this method, the panel should no longer be used.
|
|
407
405
|
*/
|
|
408
406
|
public destroy(): void {
|
|
409
407
|
this._resetInternalStates();
|
|
@@ -411,11 +409,10 @@ class Panel {
|
|
|
411
409
|
}
|
|
412
410
|
|
|
413
411
|
/**
|
|
414
|
-
* Check whether the given position is inside of this panel's {@link Panel
|
|
415
|
-
* @
|
|
416
|
-
* @param {
|
|
417
|
-
* @
|
|
418
|
-
* @return {boolean} A Boolean value indicating whether the given position is included in the panel range<ko>해당 좌표가 패널 영역 내에 속해있는지 여부</ko>
|
|
412
|
+
* Check whether the given position is inside of this panel's {@link Panel.range | range}
|
|
413
|
+
* @param pos - A position to check
|
|
414
|
+
* @param includeMargin - Include {@link Panel.margin | margin} to the range
|
|
415
|
+
* @returns A Boolean value indicating whether the given position is included in the panel range
|
|
419
416
|
*/
|
|
420
417
|
public includePosition(pos: number, includeMargin: boolean = false): boolean {
|
|
421
418
|
return this.includeRange(pos, pos, includeMargin);
|
|
@@ -423,11 +420,10 @@ class Panel {
|
|
|
423
420
|
|
|
424
421
|
/**
|
|
425
422
|
* Check whether the given range is fully included in this panel's area (inclusive)
|
|
426
|
-
* @
|
|
427
|
-
* @param
|
|
428
|
-
* @param
|
|
429
|
-
* @
|
|
430
|
-
* @returns {boolean} A Boolean value indicating whether the given range is fully included in the panel range<ko>해당 범위가 패널 영역 내에 완전히 속해있는지 여부</ko>
|
|
423
|
+
* @param min - Minimum value of the range to check
|
|
424
|
+
* @param max - Maximum value of the range to check
|
|
425
|
+
* @param includeMargin - Include {@link Panel.margin | margin} to the range
|
|
426
|
+
* @returns A Boolean value indicating whether the given range is fully included in the panel range
|
|
431
427
|
*/
|
|
432
428
|
public includeRange(min: number, max: number, includeMargin: boolean = false): boolean {
|
|
433
429
|
const margin = this._margin;
|
|
@@ -443,10 +439,9 @@ class Panel {
|
|
|
443
439
|
|
|
444
440
|
/**
|
|
445
441
|
* Check whether the panel is visble in the given range (exclusive)
|
|
446
|
-
* @
|
|
447
|
-
* @param
|
|
448
|
-
* @
|
|
449
|
-
* @returns {boolean} A Boolean value indicating whether the panel is visible<ko>해당 범위 내에서 패널을 볼 수 있는지 여부</ko>
|
|
442
|
+
* @param min - Minimum value of the range to check
|
|
443
|
+
* @param max - Maximum value of the range to check
|
|
444
|
+
* @returns A Boolean value indicating whether the panel is visible
|
|
450
445
|
*/
|
|
451
446
|
public isVisibleOnRange(min: number, max: number): boolean {
|
|
452
447
|
const panelRange = this.range;
|
|
@@ -456,20 +451,23 @@ class Panel {
|
|
|
456
451
|
|
|
457
452
|
/**
|
|
458
453
|
* Move {@link Camera} to this panel
|
|
459
|
-
* @
|
|
460
|
-
*
|
|
461
|
-
* @
|
|
462
|
-
|
|
463
|
-
|
|
454
|
+
* @remarks
|
|
455
|
+
* This is equivalent to calling `Flicking.moveTo(panel.index, duration)`.
|
|
456
|
+
* @param duration - Duration of the animation (unit: ms). Defaults to {@link FlickingOptions.duration}
|
|
457
|
+
* @fires {@link MovementEvents}
|
|
458
|
+
* @throws {@link MovementErrors}
|
|
459
|
+
* @returns A Promise which will be resolved after reaching the panel
|
|
460
|
+
*/
|
|
461
|
+
public focus(duration?: number): Promise<void> {
|
|
464
462
|
return this._flicking.moveTo(this._index, duration);
|
|
465
463
|
}
|
|
466
464
|
|
|
467
465
|
/**
|
|
468
|
-
* Get previous(`index - 1`) panel.
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
* {@link Flicking
|
|
472
|
-
* @returns
|
|
466
|
+
* Get previous(`index - 1`) panel.
|
|
467
|
+
* @remarks
|
|
468
|
+
* When the previous panel does not exist, this will return `null` instead
|
|
469
|
+
* If the {@link Flicking.circularEnabled | circular} is enabled, this will return the last panel if called from the first panel
|
|
470
|
+
* @returns The previous panel
|
|
473
471
|
*/
|
|
474
472
|
public prev(): Panel | null {
|
|
475
473
|
const index = this._index;
|
|
@@ -485,11 +483,11 @@ class Panel {
|
|
|
485
483
|
}
|
|
486
484
|
|
|
487
485
|
/**
|
|
488
|
-
* Get next(`index + 1`) panel.
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
* {@link Flicking
|
|
492
|
-
* @returns
|
|
486
|
+
* Get next(`index + 1`) panel.
|
|
487
|
+
* @remarks
|
|
488
|
+
* When the next panel does not exist, this will return `null` instead
|
|
489
|
+
* If the {@link Flicking.circularEnabled | circular} is enabled, this will return the first panel if called from the last panel
|
|
490
|
+
* @returns The next panel
|
|
493
491
|
*/
|
|
494
492
|
public next(): Panel | null {
|
|
495
493
|
const index = this._index;
|
|
@@ -505,12 +503,9 @@ class Panel {
|
|
|
505
503
|
}
|
|
506
504
|
|
|
507
505
|
/**
|
|
508
|
-
* Increase panel's index by the given value
|
|
509
|
-
* @ko 패널의 인덱스를 주어진 값만큼 증가시킵니다
|
|
510
506
|
* @internal
|
|
511
|
-
* @
|
|
512
|
-
*
|
|
513
|
-
* @returns {this}
|
|
507
|
+
* @privateRemarks
|
|
508
|
+
* Increases the panel's index by the given value. Called when panels are inserted before this panel.
|
|
514
509
|
*/
|
|
515
510
|
public increaseIndex(val: number): this {
|
|
516
511
|
this._index += Math.max(val, 0);
|
|
@@ -518,12 +513,9 @@ class Panel {
|
|
|
518
513
|
}
|
|
519
514
|
|
|
520
515
|
/**
|
|
521
|
-
* Decrease panel's index by the given value
|
|
522
|
-
* @ko 패널의 인덱스를 주어진 값만큼 감소시킵니다
|
|
523
516
|
* @internal
|
|
524
|
-
* @
|
|
525
|
-
*
|
|
526
|
-
* @returns {this}
|
|
517
|
+
* @privateRemarks
|
|
518
|
+
* Decreases the panel's index by the given value. Called when panels are removed before this panel.
|
|
527
519
|
*/
|
|
528
520
|
public decreaseIndex(val: number): this {
|
|
529
521
|
this._index -= Math.max(val, 0);
|
|
@@ -532,20 +524,21 @@ class Panel {
|
|
|
532
524
|
|
|
533
525
|
/**
|
|
534
526
|
* @internal
|
|
527
|
+
* @privateRemarks
|
|
528
|
+
* Recalculates the panel's position based on the previous panel's position and margins.
|
|
535
529
|
*/
|
|
536
530
|
public updatePosition(): this {
|
|
537
531
|
const prevPanel = this._flicking.renderer.panels[this._index - 1];
|
|
538
532
|
|
|
539
|
-
this._pos = prevPanel
|
|
540
|
-
? prevPanel.range.max + prevPanel.margin.next + this._margin.prev
|
|
541
|
-
: this._margin.prev;
|
|
533
|
+
this._pos = prevPanel ? prevPanel.range.max + prevPanel.margin.next + this._margin.prev : this._margin.prev;
|
|
542
534
|
|
|
543
535
|
return this;
|
|
544
536
|
}
|
|
545
537
|
|
|
546
538
|
/**
|
|
547
539
|
* @internal
|
|
548
|
-
* @
|
|
540
|
+
* @privateRemarks
|
|
541
|
+
* Toggles the panel's position for circular mode. Returns true if the panel was toggled.
|
|
549
542
|
*/
|
|
550
543
|
public toggle(prevPos: number, newPos: number): boolean {
|
|
551
544
|
const toggleDirection = this._toggleDirection;
|
|
@@ -570,6 +563,8 @@ class Panel {
|
|
|
570
563
|
|
|
571
564
|
/**
|
|
572
565
|
* @internal
|
|
566
|
+
* @privateRemarks
|
|
567
|
+
* Updates the toggle direction for circular mode based on the panel's visibility at the camera range edges.
|
|
573
568
|
*/
|
|
574
569
|
public updateCircularToggleDirection(): this {
|
|
575
570
|
const flicking = this._flicking;
|
|
@@ -610,10 +605,20 @@ class Panel {
|
|
|
610
605
|
return this;
|
|
611
606
|
}
|
|
612
607
|
|
|
608
|
+
/**
|
|
609
|
+
* @internal
|
|
610
|
+
* @privateRemarks
|
|
611
|
+
* Recalculates the align position based on the align option and panel size.
|
|
612
|
+
*/
|
|
613
613
|
private _updateAlignPos() {
|
|
614
614
|
this._alignPos = parseAlign(this._align, this._size);
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
+
/**
|
|
618
|
+
* @internal
|
|
619
|
+
* @privateRemarks
|
|
620
|
+
* Resets all internal state values to their defaults.
|
|
621
|
+
*/
|
|
617
622
|
private _resetInternalStates() {
|
|
618
623
|
this._size = 0;
|
|
619
624
|
this._pos = 0;
|