@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/camera/Camera.ts
CHANGED
|
@@ -3,25 +3,44 @@
|
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import { ComponentEvent } from "@egjs/component";
|
|
6
|
-
|
|
7
|
-
import Flicking, { FlickingOptions } from "../Flicking";
|
|
8
|
-
import FlickingError from "../core/FlickingError";
|
|
9
|
-
import Panel from "../core/panel/Panel";
|
|
6
|
+
import { ALIGN, CIRCULAR_FALLBACK, DIRECTION, ORDER } from "../constants/values";
|
|
10
7
|
import AnchorPoint from "../core/AnchorPoint";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
import {
|
|
8
|
+
import Panel from "../core/panel/Panel";
|
|
9
|
+
import * as ERROR from "../error/codes";
|
|
10
|
+
import FlickingError from "../error/FlickingError";
|
|
11
|
+
import { EVENTS } from "../event/names";
|
|
12
|
+
import Flicking, { FlickingOptions } from "../Flicking";
|
|
13
|
+
import { ValueOf } from "../types/internal";
|
|
14
|
+
import {
|
|
15
|
+
checkExistence,
|
|
16
|
+
find,
|
|
17
|
+
getFlickingAttached,
|
|
18
|
+
getProgress,
|
|
19
|
+
getStyle,
|
|
20
|
+
includes,
|
|
21
|
+
parseAlign,
|
|
22
|
+
toArray
|
|
23
|
+
} from "../utils";
|
|
24
|
+
|
|
25
|
+
import { BoundCameraMode, CameraMode, CircularCameraMode, LinearCameraMode } from "./mode";
|
|
17
26
|
|
|
18
27
|
export interface CameraOptions {
|
|
19
28
|
align: FlickingOptions["align"];
|
|
20
29
|
}
|
|
21
30
|
|
|
31
|
+
/**
|
|
32
|
+
* A range with minimum and maximum values
|
|
33
|
+
*/
|
|
34
|
+
export interface CameraRange {
|
|
35
|
+
/** A minimum position */
|
|
36
|
+
min: number;
|
|
37
|
+
/** A maximum position */
|
|
38
|
+
max: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
22
41
|
/**
|
|
23
42
|
* A component that manages actual movement inside the viewport
|
|
24
|
-
* @
|
|
43
|
+
* @public
|
|
25
44
|
*/
|
|
26
45
|
class Camera {
|
|
27
46
|
// Options
|
|
@@ -38,7 +57,7 @@ class Camera {
|
|
|
38
57
|
private _offset: number;
|
|
39
58
|
private _circularOffset: number;
|
|
40
59
|
private _circularEnabled: boolean;
|
|
41
|
-
private _range:
|
|
60
|
+
private _range: CameraRange;
|
|
42
61
|
private _visiblePanels: Panel[];
|
|
43
62
|
private _anchors: AnchorPoint[];
|
|
44
63
|
private _needPanelTriggered: { prev: boolean; next: boolean };
|
|
@@ -47,133 +66,122 @@ class Camera {
|
|
|
47
66
|
// Internal states getter
|
|
48
67
|
/**
|
|
49
68
|
* The camera element(`.flicking-camera`)
|
|
50
|
-
* @ko 카메라 엘리먼트(`.flicking-camera`)
|
|
51
|
-
* @type {HTMLElement}
|
|
52
69
|
* @readonly
|
|
53
70
|
*/
|
|
54
|
-
public get element() {
|
|
71
|
+
public get element(): HTMLElement {
|
|
72
|
+
return this._el;
|
|
73
|
+
}
|
|
55
74
|
/**
|
|
56
75
|
* An array of the child elements of the camera element(`.flicking-camera`)
|
|
57
|
-
* @ko 카메라 엘리먼트(`.flicking-camera`)의 자식 엘리먼트 배열
|
|
58
|
-
* @type {HTMLElement[]}
|
|
59
76
|
* @readonly
|
|
60
77
|
*/
|
|
61
|
-
public get children()
|
|
78
|
+
public get children(): HTMLElement[] {
|
|
79
|
+
return toArray(this._el.children) as HTMLElement[];
|
|
80
|
+
}
|
|
62
81
|
/**
|
|
63
82
|
* Current position of the camera
|
|
64
|
-
* @ko Camera의 현재 좌표
|
|
65
|
-
* @type {number}
|
|
66
83
|
* @readonly
|
|
67
84
|
*/
|
|
68
|
-
public get position() {
|
|
85
|
+
public get position(): number {
|
|
86
|
+
return this._position;
|
|
87
|
+
}
|
|
69
88
|
/**
|
|
70
|
-
* Align position inside the viewport where {@link Panel}'s {@link Panel
|
|
71
|
-
* @ko 패널의 정렬 기준 위치. 뷰포트 내에서 {@link Panel}의 {@link Panel#alignPosition alignPosition}이 위치해야 하는 곳입니다
|
|
72
|
-
* @type {number}
|
|
89
|
+
* Align position inside the viewport where {@link Panel}'s {@link Panel.alignPosition | alignPosition} should be located at
|
|
73
90
|
* @readonly
|
|
74
91
|
*/
|
|
75
|
-
public get alignPosition() {
|
|
92
|
+
public get alignPosition(): number {
|
|
93
|
+
return this._alignPos;
|
|
94
|
+
}
|
|
76
95
|
/**
|
|
77
|
-
* Position offset, used for the {@link Flicking
|
|
78
|
-
* @
|
|
79
|
-
* @type {number}
|
|
80
|
-
* @default 0
|
|
96
|
+
* Position offset, used for the {@link Flicking.renderOnlyVisible | renderOnlyVisible} option
|
|
97
|
+
* @defaultValue 0
|
|
81
98
|
* @readonly
|
|
82
99
|
*/
|
|
83
|
-
public get offset() {
|
|
100
|
+
public get offset(): number {
|
|
101
|
+
return this._offset - this._circularOffset;
|
|
102
|
+
}
|
|
84
103
|
/**
|
|
85
104
|
* Whether the `circular` option is enabled.
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* @type {boolean}
|
|
90
|
-
* @default false
|
|
105
|
+
* @remarks
|
|
106
|
+
* The {@link Flicking.circular | circular} option can't be enabled when sum of the panel sizes are too small.
|
|
107
|
+
* @defaultValue false
|
|
91
108
|
* @readonly
|
|
92
109
|
*/
|
|
93
|
-
public get circularEnabled() {
|
|
110
|
+
public get circularEnabled(): boolean {
|
|
111
|
+
return this._circularEnabled;
|
|
112
|
+
}
|
|
94
113
|
/**
|
|
95
114
|
* A current camera mode
|
|
96
|
-
* @type {CameraMode}
|
|
97
115
|
* @readonly
|
|
98
116
|
*/
|
|
99
|
-
public get mode() {
|
|
117
|
+
public get mode(): CameraMode {
|
|
118
|
+
return this._mode;
|
|
119
|
+
}
|
|
100
120
|
/**
|
|
101
|
-
* A range that Camera's {@link Camera
|
|
102
|
-
* @ko Camera의 {@link Camera#position position}이 도달 가능한 범위
|
|
103
|
-
* @type {object}
|
|
104
|
-
* @property {number} min A minimum position<ko>최소 위치</ko>
|
|
105
|
-
* @property {number} max A maximum position<ko>최대 위치</ko>
|
|
121
|
+
* A range that Camera's {@link Camera.position | position} can reach
|
|
106
122
|
* @readonly
|
|
107
123
|
*/
|
|
108
|
-
public get range() {
|
|
124
|
+
public get range(): CameraRange {
|
|
125
|
+
return this._range;
|
|
126
|
+
}
|
|
109
127
|
/**
|
|
110
128
|
* A difference between Camera's minimum and maximum position that can reach
|
|
111
|
-
* @ko Camera가 도달 가능한 최소/최대 좌표의 차이
|
|
112
|
-
* @type {number}
|
|
113
129
|
* @readonly
|
|
114
130
|
*/
|
|
115
|
-
public get rangeDiff() {
|
|
131
|
+
public get rangeDiff(): number {
|
|
132
|
+
return this._range.max - this._range.min;
|
|
133
|
+
}
|
|
116
134
|
/**
|
|
117
135
|
* An array of visible panels from the current position
|
|
118
|
-
* @ko 현재 보이는 패널들의 배열
|
|
119
|
-
* @type {Panel[]}
|
|
120
136
|
* @readonly
|
|
121
137
|
*/
|
|
122
|
-
public get visiblePanels() {
|
|
138
|
+
public get visiblePanels(): Panel[] {
|
|
139
|
+
return this._visiblePanels;
|
|
140
|
+
}
|
|
123
141
|
/**
|
|
124
142
|
* A range of the visible area from the current position
|
|
125
|
-
* @ko 현재 위치에서 보이는 범위
|
|
126
|
-
* @type {object}
|
|
127
|
-
* @property {number} min A minimum position<ko>최소 위치</ko>
|
|
128
|
-
* @property {number} min A maximum position<ko>최대 위치</ko>
|
|
129
143
|
* @readonly
|
|
130
144
|
*/
|
|
131
|
-
public get visibleRange()
|
|
145
|
+
public get visibleRange(): CameraRange {
|
|
146
|
+
return { min: this._position - this._alignPos, max: this._position - this._alignPos + this.size };
|
|
147
|
+
}
|
|
132
148
|
/**
|
|
133
149
|
* An array of {@link AnchorPoint}s that Camera can be stopped at
|
|
134
|
-
* @ko 카메라가 도달 가능한 {@link AnchorPoint}의 목록
|
|
135
|
-
* @type {AnchorPoint[]}
|
|
136
150
|
* @readonly
|
|
137
151
|
*/
|
|
138
|
-
public get anchorPoints() {
|
|
152
|
+
public get anchorPoints(): AnchorPoint[] {
|
|
153
|
+
return this._anchors;
|
|
154
|
+
}
|
|
139
155
|
/**
|
|
140
156
|
* A current parameters of the Camera for updating {@link AxesController}
|
|
141
|
-
* @ko {@link AxesController}를 업데이트하기 위한 현재 Camera 패러미터들
|
|
142
|
-
* @type {ControlParams}
|
|
143
157
|
* @readonly
|
|
144
158
|
*/
|
|
145
|
-
public get controlParams() {
|
|
159
|
+
public get controlParams(): { range: CameraRange; position: number; circular: boolean } {
|
|
160
|
+
return { range: this._range, position: this._position, circular: this._circularEnabled };
|
|
161
|
+
}
|
|
146
162
|
/**
|
|
147
163
|
* A Boolean value indicating whether Camera's over the minimum or maximum position reachable
|
|
148
|
-
* @ko 현재 카메라가 도달 가능한 범위의 최소 혹은 최대점을 넘어섰는지를 나타냅니다
|
|
149
|
-
* @type {boolean}
|
|
150
164
|
* @readonly
|
|
151
165
|
*/
|
|
152
|
-
public get atEdge() {
|
|
166
|
+
public get atEdge(): boolean {
|
|
167
|
+
return this._position <= this._range.min || this._position >= this._range.max;
|
|
168
|
+
}
|
|
153
169
|
/**
|
|
154
170
|
* Return the size of the viewport
|
|
155
|
-
* @ko 뷰포트 크기를 반환합니다
|
|
156
|
-
* @type {number}
|
|
157
171
|
* @readonly
|
|
158
172
|
*/
|
|
159
|
-
public get size() {
|
|
173
|
+
public get size(): number {
|
|
160
174
|
const flicking = this._flicking;
|
|
161
|
-
return flicking
|
|
162
|
-
? flicking.horizontal
|
|
163
|
-
? flicking.viewport.width
|
|
164
|
-
: flicking.viewport.height
|
|
165
|
-
: 0;
|
|
175
|
+
return flicking ? (flicking.horizontal ? flicking.viewport.width : flicking.viewport.height) : 0;
|
|
166
176
|
}
|
|
167
177
|
|
|
168
178
|
/**
|
|
169
179
|
* Return the camera's position progress from the first panel to last panel
|
|
180
|
+
* @remarks
|
|
170
181
|
* Range is from 0 to last panel's index
|
|
171
|
-
* @ko 첫번째 패널로부터 마지막 패널까지의 카메라 위치의 진행도를 반환합니다
|
|
172
|
-
* 범위는 0부터 마지막 패널의 인덱스까지입니다
|
|
173
|
-
* @type {number}
|
|
174
182
|
* @readonly
|
|
175
183
|
*/
|
|
176
|
-
public get progress() {
|
|
184
|
+
public get progress(): number {
|
|
177
185
|
const flicking = this._flicking;
|
|
178
186
|
const position = this._position + this._offset;
|
|
179
187
|
const nearestAnchor = this.findNearestAnchor(this._position);
|
|
@@ -195,9 +203,7 @@ class Camera {
|
|
|
195
203
|
|
|
196
204
|
if (position < panelPos) {
|
|
197
205
|
const prevPanel = nearestPanel.prev();
|
|
198
|
-
let prevPosition = prevPanel
|
|
199
|
-
? prevPanel.position + prevPanel.offset
|
|
200
|
-
: prevRange - bounceSize[0];
|
|
206
|
+
let prevPosition = prevPanel ? prevPanel.position + prevPanel.offset : prevRange - bounceSize[0];
|
|
201
207
|
|
|
202
208
|
// Looped
|
|
203
209
|
if (prevPosition > panelPos) {
|
|
@@ -207,9 +213,7 @@ class Camera {
|
|
|
207
213
|
return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
|
|
208
214
|
} else {
|
|
209
215
|
const nextPanel = nearestPanel.next();
|
|
210
|
-
let nextPosition = nextPanel
|
|
211
|
-
? nextPanel.position + nextPanel.offset
|
|
212
|
-
: nextRange + bounceSize[1];
|
|
216
|
+
let nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1];
|
|
213
217
|
|
|
214
218
|
// Looped
|
|
215
219
|
if (nextPosition < panelPos) {
|
|
@@ -221,30 +225,32 @@ class Camera {
|
|
|
221
225
|
}
|
|
222
226
|
|
|
223
227
|
/**
|
|
224
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element(`.flicking-camera`)
|
|
225
|
-
* @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성
|
|
226
|
-
* @type {string}
|
|
228
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction | direction} CSS property applied to the camera element(`.flicking-camera`)
|
|
227
229
|
* @readonly
|
|
228
230
|
*/
|
|
229
|
-
public get panelOrder()
|
|
231
|
+
public get panelOrder(): ValueOf<typeof ORDER> {
|
|
232
|
+
return this._panelOrder;
|
|
233
|
+
}
|
|
230
234
|
|
|
231
235
|
// Options Getter
|
|
232
236
|
/**
|
|
233
|
-
* A value indicating where the {@link Camera
|
|
234
|
-
* @ko {@link Camera#alignPosition alignPosition}이 뷰포트 엘리먼트 내의 어디에 위치해야 하는지를 나타내는 값
|
|
235
|
-
* @type {ALIGN | string | number}
|
|
237
|
+
* A value indicating where the {@link Camera.alignPosition | alignPosition} should be located at inside the viewport element
|
|
236
238
|
*/
|
|
237
|
-
public get align() {
|
|
239
|
+
public get align(): FlickingOptions["align"] {
|
|
240
|
+
return this._align;
|
|
241
|
+
}
|
|
238
242
|
|
|
239
243
|
// Options Setter
|
|
240
244
|
public set align(val: FlickingOptions["align"]) {
|
|
241
245
|
this._align = val;
|
|
242
246
|
}
|
|
243
247
|
|
|
244
|
-
/**
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
+
/**
|
|
249
|
+
* Creates a new Camera instance
|
|
250
|
+
* @param flicking - An instance of {@link Flicking}
|
|
251
|
+
* @param options - Options for the Camera
|
|
252
|
+
*/
|
|
253
|
+
public constructor(flicking: Flicking, { align = ALIGN.CENTER }: Partial<CameraOptions> = {}) {
|
|
248
254
|
this._flicking = flicking;
|
|
249
255
|
this._resetInternalValues();
|
|
250
256
|
|
|
@@ -254,11 +260,10 @@ class Camera {
|
|
|
254
260
|
|
|
255
261
|
/**
|
|
256
262
|
* Initialize Camera
|
|
257
|
-
* @
|
|
258
|
-
* @
|
|
259
|
-
* {@link
|
|
260
|
-
*
|
|
261
|
-
* @return {this}
|
|
263
|
+
* @remarks
|
|
264
|
+
* This method is called automatically during {@link Flicking.init}. It finds the camera element inside the viewport.
|
|
265
|
+
* @throws {@link InitializationErrors}
|
|
266
|
+
* @returns The current instance for method chaining
|
|
262
267
|
*/
|
|
263
268
|
public init(): this {
|
|
264
269
|
const viewportEl = this._flicking.viewport.element;
|
|
@@ -275,8 +280,9 @@ class Camera {
|
|
|
275
280
|
|
|
276
281
|
/**
|
|
277
282
|
* Destroy Camera and return to initial state
|
|
278
|
-
* @
|
|
279
|
-
*
|
|
283
|
+
* @remarks
|
|
284
|
+
* This method resets all internal values to their initial state.
|
|
285
|
+
* @returns The current instance for method chaining
|
|
280
286
|
*/
|
|
281
287
|
public destroy(): this {
|
|
282
288
|
this._resetInternalValues();
|
|
@@ -285,12 +291,10 @@ class Camera {
|
|
|
285
291
|
|
|
286
292
|
/**
|
|
287
293
|
* Move to the given position and apply CSS transform
|
|
288
|
-
* @
|
|
289
|
-
*
|
|
290
|
-
* @
|
|
291
|
-
*
|
|
292
|
-
* <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
|
|
293
|
-
* @return {this}
|
|
294
|
+
* @remarks
|
|
295
|
+
* This method updates the camera position, toggles panels for circular mode, and refreshes visible panels.
|
|
296
|
+
* @param pos - A new position
|
|
297
|
+
* @throws {@link InitializationErrors}
|
|
294
298
|
*/
|
|
295
299
|
public lookAt(pos: number): void {
|
|
296
300
|
const prevOffset = this._offset;
|
|
@@ -320,11 +324,10 @@ class Camera {
|
|
|
320
324
|
|
|
321
325
|
/**
|
|
322
326
|
* Return a previous {@link AnchorPoint} of given {@link AnchorPoint}
|
|
327
|
+
* @remarks
|
|
323
328
|
* If it does not exist, return `null` instead
|
|
324
|
-
* @
|
|
325
|
-
*
|
|
326
|
-
* @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
|
|
327
|
-
* @return {AnchorPoint | null} The previous {@link AnchorPoint}<ko>이전 {@link AnchorPoint}</ko>
|
|
329
|
+
* @param anchor - A reference {@link AnchorPoint}
|
|
330
|
+
* @returns The previous {@link AnchorPoint}
|
|
328
331
|
*/
|
|
329
332
|
public getPrevAnchor(anchor: AnchorPoint): AnchorPoint | null {
|
|
330
333
|
if (!this._circularEnabled || anchor.index !== 0) {
|
|
@@ -344,11 +347,10 @@ class Camera {
|
|
|
344
347
|
|
|
345
348
|
/**
|
|
346
349
|
* Return a next {@link AnchorPoint} of given {@link AnchorPoint}
|
|
350
|
+
* @remarks
|
|
347
351
|
* If it does not exist, return `null` instead
|
|
348
|
-
* @
|
|
349
|
-
*
|
|
350
|
-
* @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
|
|
351
|
-
* @return {AnchorPoint | null} The next {@link AnchorPoint}<ko>다음 {@link AnchorPoint}</ko>
|
|
352
|
+
* @param anchor - A reference {@link AnchorPoint}
|
|
353
|
+
* @returns The next {@link AnchorPoint}
|
|
352
354
|
*/
|
|
353
355
|
public getNextAnchor(anchor: AnchorPoint): AnchorPoint | null {
|
|
354
356
|
const anchors = this._anchors;
|
|
@@ -369,13 +371,13 @@ class Camera {
|
|
|
369
371
|
|
|
370
372
|
/**
|
|
371
373
|
* Return the camera's position progress in the panel below
|
|
372
|
-
*
|
|
374
|
+
* @remarks
|
|
375
|
+
* Value is from 0 to 1 when the camera's inside panel.
|
|
373
376
|
* Value can be lower than 0 or bigger than 1 when it's in the margin area
|
|
374
|
-
* @
|
|
375
|
-
*
|
|
376
|
-
* 패널의 margin 영역에 있을 경우 0보다 작거나 1보다 큰 값을 반환할 수 있습니다
|
|
377
|
+
* @param panel - A panel to check
|
|
378
|
+
* @returns Progress value from 0 to 1 (or outside this range when in margin area)
|
|
377
379
|
*/
|
|
378
|
-
public getProgressInPanel(panel: Panel) {
|
|
380
|
+
public getProgressInPanel(panel: Panel): number {
|
|
379
381
|
const panelRange = panel.range;
|
|
380
382
|
|
|
381
383
|
return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
|
|
@@ -383,11 +385,10 @@ class Camera {
|
|
|
383
385
|
|
|
384
386
|
/**
|
|
385
387
|
* Return {@link AnchorPoint} that includes given position
|
|
388
|
+
* @remarks
|
|
386
389
|
* If there's no {@link AnchorPoint} that includes the given position, return `null` instead
|
|
387
|
-
* @
|
|
388
|
-
*
|
|
389
|
-
* @param {number} position A position to check<ko>확인할 좌표</ko>
|
|
390
|
-
* @return {AnchorPoint | null} The {@link AnchorPoint} that includes the given position<ko>해당 좌표를 포함하는 {@link AnchorPoint}</ko>
|
|
390
|
+
* @param position - A position to check
|
|
391
|
+
* @returns The {@link AnchorPoint} that includes the given position
|
|
391
392
|
*/
|
|
392
393
|
public findAnchorIncludePosition(position: number): AnchorPoint | null {
|
|
393
394
|
return this._mode.findAnchorIncludePosition(position);
|
|
@@ -395,20 +396,18 @@ class Camera {
|
|
|
395
396
|
|
|
396
397
|
/**
|
|
397
398
|
* Return {@link AnchorPoint} nearest to given position
|
|
399
|
+
* @remarks
|
|
398
400
|
* If there're no {@link AnchorPoint}s, return `null` instead
|
|
399
|
-
* @
|
|
400
|
-
* {@link AnchorPoint}
|
|
401
|
-
* @param {number} position A position to check<ko>확인할 좌표</ko>
|
|
402
|
-
* @return {AnchorPoint | null} The {@link AnchorPoint} nearest to the given position<ko>해당 좌표에 가장 인접한 {@link AnchorPoint}</ko>
|
|
401
|
+
* @param position - A position to check
|
|
402
|
+
* @returns The {@link AnchorPoint} nearest to the given position
|
|
403
403
|
*/
|
|
404
404
|
public findNearestAnchor(position: number): AnchorPoint | null {
|
|
405
405
|
return this._mode.findNearestAnchor(position);
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
/**
|
|
409
|
-
* Return {@link AnchorPoint} that matches {@link Flicking
|
|
410
|
-
* @
|
|
411
|
-
* @return {AnchorPoint | null}
|
|
409
|
+
* Return {@link AnchorPoint} that matches {@link Flicking.currentPanel}
|
|
410
|
+
* @returns The {@link AnchorPoint} that matches current panel
|
|
412
411
|
*/
|
|
413
412
|
public findActiveAnchor(): AnchorPoint | null {
|
|
414
413
|
const flicking = getFlickingAttached(this._flicking);
|
|
@@ -416,14 +415,16 @@ class Camera {
|
|
|
416
415
|
|
|
417
416
|
if (!activePanel) return null;
|
|
418
417
|
|
|
419
|
-
return
|
|
418
|
+
return (
|
|
419
|
+
find(this._anchors, anchor => anchor.panel.index === activePanel.index) ??
|
|
420
|
+
this.findNearestAnchor(activePanel.position)
|
|
421
|
+
);
|
|
420
422
|
}
|
|
421
423
|
|
|
422
424
|
/**
|
|
423
425
|
* Clamp the given position between camera's range
|
|
424
|
-
* @
|
|
425
|
-
* @
|
|
426
|
-
* @return {number} A clamped position<ko>범위 제한된 좌표</ko>
|
|
426
|
+
* @param position - A position to clamp
|
|
427
|
+
* @returns A clamped position
|
|
427
428
|
*/
|
|
428
429
|
public clampToReachablePosition(position: number): number {
|
|
429
430
|
return this._mode.clampToReachablePosition(position);
|
|
@@ -431,9 +432,8 @@ class Camera {
|
|
|
431
432
|
|
|
432
433
|
/**
|
|
433
434
|
* Check whether the given panel is inside of the Camera's range
|
|
434
|
-
* @
|
|
435
|
-
* @
|
|
436
|
-
* @return {boolean} Whether the panel's inside Camera's range<ko>도달 가능한 범위 내에 해당 패널이 존재하는지 여부</ko>
|
|
435
|
+
* @param panel - An instance of {@link Panel} to check
|
|
436
|
+
* @returns Whether the panel's inside Camera's range
|
|
437
437
|
*/
|
|
438
438
|
public canReach(panel: Panel): boolean {
|
|
439
439
|
return this._mode.canReach(panel);
|
|
@@ -441,29 +441,21 @@ class Camera {
|
|
|
441
441
|
|
|
442
442
|
/**
|
|
443
443
|
* Check whether the given panel element is visible at the current position
|
|
444
|
-
* @
|
|
445
|
-
* @
|
|
446
|
-
* @return Whether the panel element is visible at the current position<ko>현재 위치에서 해당 패널 엘리먼트가 보이는지 여부</ko>
|
|
444
|
+
* @param panel - An instance of {@link Panel} to check
|
|
445
|
+
* @returns Whether the panel element is visible at the current position
|
|
447
446
|
*/
|
|
448
447
|
public canSee(panel: Panel): boolean {
|
|
449
448
|
return this._mode.canSee(panel);
|
|
450
449
|
}
|
|
451
450
|
|
|
452
451
|
/**
|
|
453
|
-
* Update {@link Camera
|
|
454
|
-
* @
|
|
455
|
-
*
|
|
456
|
-
* @
|
|
457
|
-
* @
|
|
458
|
-
* @instance
|
|
459
|
-
* @name updateRange
|
|
460
|
-
* @chainable
|
|
461
|
-
* @throws {FlickingError}
|
|
462
|
-
* {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
|
|
463
|
-
* <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
|
|
464
|
-
* @return {this}
|
|
452
|
+
* Update {@link Camera.range | range} of Camera
|
|
453
|
+
* @remarks
|
|
454
|
+
* This method recalculates the camera range based on the current panel positions and circular mode settings.
|
|
455
|
+
* @throws {@link InitializationErrors}
|
|
456
|
+
* @returns The current instance for method chaining
|
|
465
457
|
*/
|
|
466
|
-
public updateRange() {
|
|
458
|
+
public updateRange(): this {
|
|
467
459
|
const flicking = getFlickingAttached(this._flicking);
|
|
468
460
|
const renderer = flicking.renderer;
|
|
469
461
|
const panels = renderer.panels;
|
|
@@ -477,17 +469,13 @@ class Camera {
|
|
|
477
469
|
}
|
|
478
470
|
|
|
479
471
|
/**
|
|
480
|
-
* Update Camera's {@link Camera
|
|
481
|
-
* @
|
|
482
|
-
* @chainable
|
|
483
|
-
* @return {this}
|
|
472
|
+
* Update Camera's {@link Camera.alignPosition | alignPosition}
|
|
473
|
+
* @returns The current instance for method chaining
|
|
484
474
|
*/
|
|
485
475
|
public updateAlignPos(): this {
|
|
486
476
|
const align = this._align;
|
|
487
477
|
|
|
488
|
-
const alignVal = typeof align === "object"
|
|
489
|
-
? (align as { camera: string | number }).camera
|
|
490
|
-
: align;
|
|
478
|
+
const alignVal = typeof align === "object" ? (align as { camera: string | number }).camera : align;
|
|
491
479
|
|
|
492
480
|
this._alignPos = parseAlign(alignVal, this.size);
|
|
493
481
|
|
|
@@ -495,13 +483,11 @@ class Camera {
|
|
|
495
483
|
}
|
|
496
484
|
|
|
497
485
|
/**
|
|
498
|
-
* Update Camera's {@link Camera
|
|
499
|
-
* @
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
* @chainable
|
|
504
|
-
* @return {this}
|
|
486
|
+
* Update Camera's {@link Camera.anchorPoints | anchorPoints}
|
|
487
|
+
* @remarks
|
|
488
|
+
* Anchor points are positions where the camera can stop. This method recalculates them based on the current mode.
|
|
489
|
+
* @throws {@link InitializationErrors}
|
|
490
|
+
* @returns The current instance for method chaining
|
|
505
491
|
*/
|
|
506
492
|
public updateAnchors(): this {
|
|
507
493
|
this._anchors = this._mode.getAnchors();
|
|
@@ -511,14 +497,11 @@ class Camera {
|
|
|
511
497
|
|
|
512
498
|
/**
|
|
513
499
|
* Update Viewport's height to visible panel's max height
|
|
514
|
-
* @
|
|
515
|
-
* @
|
|
516
|
-
*
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
* @return {this}
|
|
520
|
-
*/
|
|
521
|
-
public updateAdaptiveHeight() {
|
|
500
|
+
* @remarks
|
|
501
|
+
* This method only takes effect when {@link FlickingOptions.horizontal | horizontal} is `true` and {@link FlickingOptions.adaptive | adaptive} is enabled.
|
|
502
|
+
* @throws {@link InitializationErrors}
|
|
503
|
+
*/
|
|
504
|
+
public updateAdaptiveHeight(): void {
|
|
522
505
|
const flicking = getFlickingAttached(this._flicking);
|
|
523
506
|
const activePanel = flicking.control.activePanel;
|
|
524
507
|
const visiblePanels = flicking.visiblePanels;
|
|
@@ -531,10 +514,8 @@ class Camera {
|
|
|
531
514
|
|
|
532
515
|
if (!flicking.horizontal || !flicking.adaptive || !selectedPanels.length) return;
|
|
533
516
|
|
|
534
|
-
|
|
535
517
|
const maxHeight = Math.max(...selectedPanels.map(panel => panel.height));
|
|
536
518
|
|
|
537
|
-
|
|
538
519
|
flicking.viewport.setSize({
|
|
539
520
|
height: maxHeight
|
|
540
521
|
});
|
|
@@ -542,9 +523,7 @@ class Camera {
|
|
|
542
523
|
|
|
543
524
|
/**
|
|
544
525
|
* Update current offset of the camera
|
|
545
|
-
* @
|
|
546
|
-
* @chainable
|
|
547
|
-
* @return {this}
|
|
526
|
+
* @returns The current instance for method chaining
|
|
548
527
|
*/
|
|
549
528
|
public updateOffset(): this {
|
|
550
529
|
const flicking = getFlickingAttached(this._flicking);
|
|
@@ -563,9 +542,8 @@ class Camera {
|
|
|
563
542
|
}
|
|
564
543
|
|
|
565
544
|
/**
|
|
566
|
-
* Update direction to match the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element
|
|
567
|
-
* @
|
|
568
|
-
* @return {this}
|
|
545
|
+
* Update direction to match the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction | direction} CSS property applied to the camera element
|
|
546
|
+
* @returns The current instance for method chaining
|
|
569
547
|
*/
|
|
570
548
|
public updatePanelOrder(): this {
|
|
571
549
|
const flicking = getFlickingAttached(this._flicking);
|
|
@@ -585,10 +563,8 @@ class Camera {
|
|
|
585
563
|
}
|
|
586
564
|
|
|
587
565
|
/**
|
|
588
|
-
* Reset the history of {@link Flicking
|
|
589
|
-
* @
|
|
590
|
-
* @chainable
|
|
591
|
-
* @return {this}
|
|
566
|
+
* Reset the history of {@link Flicking.event:needPanel | needPanel} events so it can be triggered again
|
|
567
|
+
* @returns The current instance for method chaining
|
|
592
568
|
*/
|
|
593
569
|
public resetNeedPanelHistory(): this {
|
|
594
570
|
this._needPanelTriggered = { prev: false, next: false };
|
|
@@ -597,8 +573,7 @@ class Camera {
|
|
|
597
573
|
|
|
598
574
|
/**
|
|
599
575
|
* Apply "transform" style with the current position to camera element
|
|
600
|
-
* @
|
|
601
|
-
* @return {this}
|
|
576
|
+
* @returns The current instance for method chaining
|
|
602
577
|
*/
|
|
603
578
|
public applyTransform(): this {
|
|
604
579
|
const el = this._el;
|
|
@@ -616,6 +591,11 @@ class Camera {
|
|
|
616
591
|
return this;
|
|
617
592
|
}
|
|
618
593
|
|
|
594
|
+
/**
|
|
595
|
+
* @internal
|
|
596
|
+
* @privateRemarks
|
|
597
|
+
* Resets all internal state values to their defaults. Called during construction and destruction.
|
|
598
|
+
*/
|
|
619
599
|
private _resetInternalValues() {
|
|
620
600
|
this._position = 0;
|
|
621
601
|
this._lookedOffset = 0;
|
|
@@ -629,6 +609,11 @@ class Camera {
|
|
|
629
609
|
this._needPanelTriggered = { prev: false, next: false };
|
|
630
610
|
}
|
|
631
611
|
|
|
612
|
+
/**
|
|
613
|
+
* @internal
|
|
614
|
+
* @privateRemarks
|
|
615
|
+
* Updates the list of visible panels and triggers {@link VisibleChangeEvent} if panels were added or removed.
|
|
616
|
+
*/
|
|
632
617
|
private _refreshVisiblePanels() {
|
|
633
618
|
const flicking = getFlickingAttached(this._flicking);
|
|
634
619
|
const panels = flicking.renderer.panels;
|
|
@@ -642,15 +627,22 @@ class Camera {
|
|
|
642
627
|
|
|
643
628
|
if (added.length > 0 || removed.length > 0) {
|
|
644
629
|
void flicking.renderer.render().then(() => {
|
|
645
|
-
flicking.trigger(
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
630
|
+
flicking.trigger(
|
|
631
|
+
new ComponentEvent(EVENTS.VISIBLE_CHANGE, {
|
|
632
|
+
added,
|
|
633
|
+
removed,
|
|
634
|
+
visiblePanels: newVisiblePanels
|
|
635
|
+
})
|
|
636
|
+
);
|
|
650
637
|
});
|
|
651
638
|
}
|
|
652
639
|
}
|
|
653
640
|
|
|
641
|
+
/**
|
|
642
|
+
* @internal
|
|
643
|
+
* @privateRemarks
|
|
644
|
+
* Checks if the camera is near the edges and triggers {@link NeedPanelEvent} for infinite scrolling implementations.
|
|
645
|
+
*/
|
|
654
646
|
private _checkNeedPanel(): void {
|
|
655
647
|
const needPanelTriggered = this._needPanelTriggered;
|
|
656
648
|
|
|
@@ -686,7 +678,7 @@ class Camera {
|
|
|
686
678
|
if (!needPanelTriggered.prev) {
|
|
687
679
|
const firstPanelPrev = firstPanel.range.min;
|
|
688
680
|
|
|
689
|
-
if (cameraPrev <=
|
|
681
|
+
if (cameraPrev <= firstPanelPrev + needPanelThreshold || cameraPosition <= cameraRange.min + needPanelThreshold) {
|
|
690
682
|
flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, { direction: DIRECTION.PREV }));
|
|
691
683
|
needPanelTriggered.prev = true;
|
|
692
684
|
}
|
|
@@ -695,13 +687,18 @@ class Camera {
|
|
|
695
687
|
if (!needPanelTriggered.next) {
|
|
696
688
|
const lastPanelNext = lastPanel.range.max;
|
|
697
689
|
|
|
698
|
-
if (cameraNext >=
|
|
690
|
+
if (cameraNext >= lastPanelNext - needPanelThreshold || cameraPosition >= cameraRange.max - needPanelThreshold) {
|
|
699
691
|
flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, { direction: DIRECTION.NEXT }));
|
|
700
692
|
needPanelTriggered.next = true;
|
|
701
693
|
}
|
|
702
694
|
}
|
|
703
695
|
}
|
|
704
696
|
|
|
697
|
+
/**
|
|
698
|
+
* @internal
|
|
699
|
+
* @privateRemarks
|
|
700
|
+
* Checks if the camera has reached the edge of the range and triggers {@link ReachEdgeEvent}.
|
|
701
|
+
*/
|
|
705
702
|
private _checkReachEnd(prevPos: number, newPos: number): void {
|
|
706
703
|
const flicking = getFlickingAttached(this._flicking);
|
|
707
704
|
const range = this._range;
|
|
@@ -713,11 +710,18 @@ class Camera {
|
|
|
713
710
|
|
|
714
711
|
const direction = newPos <= range.min ? DIRECTION.PREV : DIRECTION.NEXT;
|
|
715
712
|
|
|
716
|
-
flicking.trigger(
|
|
717
|
-
|
|
718
|
-
|
|
713
|
+
flicking.trigger(
|
|
714
|
+
new ComponentEvent(EVENTS.REACH_EDGE, {
|
|
715
|
+
direction
|
|
716
|
+
})
|
|
717
|
+
);
|
|
719
718
|
}
|
|
720
719
|
|
|
720
|
+
/**
|
|
721
|
+
* @internal
|
|
722
|
+
* @privateRemarks
|
|
723
|
+
* Checks for CSS transform support and stores the vendor-prefixed property name. Throws if transforms are not supported.
|
|
724
|
+
*/
|
|
721
725
|
private _checkTranslateSupport = () => {
|
|
722
726
|
const transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
|
|
723
727
|
|
|
@@ -736,6 +740,11 @@ class Camera {
|
|
|
736
740
|
this._transform = transformName;
|
|
737
741
|
};
|
|
738
742
|
|
|
743
|
+
/**
|
|
744
|
+
* @internal
|
|
745
|
+
* @privateRemarks
|
|
746
|
+
* Updates the camera mode based on {@link FlickingOptions.circular | circular} and {@link FlickingOptions.bound | bound} options.
|
|
747
|
+
*/
|
|
739
748
|
private _updateMode() {
|
|
740
749
|
const flicking = getFlickingAttached(this._flicking);
|
|
741
750
|
|
|
@@ -748,20 +757,22 @@ class Camera {
|
|
|
748
757
|
} else {
|
|
749
758
|
const fallbackMode = flicking.circularFallback;
|
|
750
759
|
|
|
751
|
-
this._mode =
|
|
752
|
-
? new BoundCameraMode(flicking)
|
|
753
|
-
: new LinearCameraMode(flicking);
|
|
760
|
+
this._mode =
|
|
761
|
+
fallbackMode === CIRCULAR_FALLBACK.BOUND ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
|
|
754
762
|
}
|
|
755
763
|
|
|
756
764
|
this._circularEnabled = canSetCircularMode;
|
|
757
765
|
} else {
|
|
758
|
-
this._mode = flicking.bound
|
|
759
|
-
? new BoundCameraMode(flicking)
|
|
760
|
-
: new LinearCameraMode(flicking);
|
|
766
|
+
this._mode = flicking.bound ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
|
|
761
767
|
this._circularEnabled = false;
|
|
762
768
|
}
|
|
763
769
|
}
|
|
764
770
|
|
|
771
|
+
/**
|
|
772
|
+
* @internal
|
|
773
|
+
* @privateRemarks
|
|
774
|
+
* Toggles panel positions for circular mode. Returns true if any panel was toggled.
|
|
775
|
+
*/
|
|
765
776
|
private _togglePanels(prevPos: number, pos: number): boolean {
|
|
766
777
|
if (pos === prevPos) return false;
|
|
767
778
|
|