@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
|
@@ -2,19 +2,22 @@
|
|
|
2
2
|
* Copyright (c) 2015 NAVER Corp.
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import { DIRECTION } from "../../
|
|
5
|
+
import { DIRECTION } from "../../constants/values";
|
|
6
6
|
import { circulateIndex } from "../../utils";
|
|
7
7
|
|
|
8
8
|
import Panel, { PanelOptions } from "./Panel";
|
|
9
9
|
import VirtualElementProvider from "./provider/VirtualElementProvider";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Options for creating a {@link VirtualPanel}
|
|
13
|
+
*/
|
|
14
|
+
export interface VirtualPanelOptions extends PanelOptions {
|
|
15
|
+
/** A provider instance that returns the actual html element */
|
|
12
16
|
elementProvider: VirtualElementProvider;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @ko 슬라이드 데이터 컴포넌트로, 단일 HTMLElement의 정보를 갖고 있습니다
|
|
20
|
+
* A slide data component that holds information of a single HTMLElement
|
|
18
21
|
*/
|
|
19
22
|
class VirtualPanel extends Panel {
|
|
20
23
|
protected _elProvider: VirtualElementProvider;
|
|
@@ -22,27 +25,25 @@ class VirtualPanel extends Panel {
|
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
* `HTMLElement` that panel's referencing
|
|
25
|
-
* @ko 패널이 참조하고 있는 `HTMLElement`
|
|
26
|
-
* @type {HTMLElement}
|
|
27
28
|
* @readonly
|
|
28
29
|
*/
|
|
29
|
-
public get element() {
|
|
30
|
+
public get element(): HTMLElement {
|
|
31
|
+
return this._elProvider.element;
|
|
32
|
+
}
|
|
30
33
|
|
|
31
34
|
/**
|
|
32
35
|
* Cached innerHTML by the previous render function
|
|
33
|
-
* @ko 이전 렌더링에서 캐시된 innerHTML 정보
|
|
34
|
-
* @type {string|null}
|
|
35
36
|
* @readonly
|
|
36
37
|
*/
|
|
37
|
-
public get cachedInnerHTML()
|
|
38
|
+
public get cachedInnerHTML(): string | null {
|
|
39
|
+
return this._cachedInnerHTML;
|
|
40
|
+
}
|
|
38
41
|
|
|
39
42
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @ko 몇 번째 엘리먼트에 렌더링될 것인지를 나타내는 숫자
|
|
42
|
-
* @type {number}
|
|
43
|
+
* A number for indexing which element it will be rendered on
|
|
43
44
|
* @readonly
|
|
44
45
|
*/
|
|
45
|
-
public get elementIndex() {
|
|
46
|
+
public get elementIndex(): number {
|
|
46
47
|
const flicking = this._flicking;
|
|
47
48
|
const virtualElCount = flicking.panelsPerView + 1;
|
|
48
49
|
const panelCount = flicking.panelCount;
|
|
@@ -50,19 +51,14 @@ class VirtualPanel extends Panel {
|
|
|
50
51
|
|
|
51
52
|
if (this._toggled) {
|
|
52
53
|
// To prevent element duplication
|
|
53
|
-
index = this._toggleDirection === DIRECTION.NEXT
|
|
54
|
-
? index + panelCount
|
|
55
|
-
: index - panelCount;
|
|
54
|
+
index = this._toggleDirection === DIRECTION.NEXT ? index + panelCount : index - panelCount;
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
return circulateIndex(index, virtualElCount);
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
/**
|
|
62
|
-
* @param
|
|
63
|
-
* @param {number} [options.index] An initial index of the panel<ko>패널의 초기 인덱스</ko>
|
|
64
|
-
* @param {Constants.ALIGN | string | number} [options.align] An initial {@link Flicking#align align} value of the panel<ko>패널의 초기 {@link Flicking#align align}값</ko>
|
|
65
|
-
* @param {Flicking} [options.flicking] A Flicking instance panel's referencing<ko>패널이 참조하는 {@link Flicking} 인스턴스</ko>
|
|
61
|
+
* @param options - {@link VirtualPanelOptions}
|
|
66
62
|
*/
|
|
67
63
|
public constructor(options: VirtualPanelOptions) {
|
|
68
64
|
super(options);
|
package/src/core/panel/index.ts
CHANGED
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
* Copyright (c) 2015 NAVER Corp.
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import Panel, { PanelOptions } from "./Panel";
|
|
6
|
-
import VirtualPanel from "./VirtualPanel";
|
|
5
|
+
import Panel, { PanelBoundingBoxRange, PanelMarginInfo, PanelOptions } from "./Panel";
|
|
6
|
+
import VirtualPanel, { VirtualPanelOptions } from "./VirtualPanel";
|
|
7
7
|
|
|
8
8
|
export * from "./provider";
|
|
9
9
|
|
|
10
|
-
export {
|
|
11
|
-
Panel,
|
|
12
|
-
VirtualPanel
|
|
13
|
-
};
|
|
10
|
+
export { Panel, VirtualPanel };
|
|
14
11
|
|
|
15
|
-
export type {
|
|
16
|
-
PanelOptions
|
|
17
|
-
};
|
|
12
|
+
export type { PanelOptions, PanelBoundingBoxRange, PanelMarginInfo, VirtualPanelOptions };
|
|
@@ -13,8 +13,12 @@ class VanillaElementProvider implements ElementProvider {
|
|
|
13
13
|
private _element: HTMLElement;
|
|
14
14
|
private _rendered: boolean;
|
|
15
15
|
|
|
16
|
-
public get element() {
|
|
17
|
-
|
|
16
|
+
public get element() {
|
|
17
|
+
return this._element;
|
|
18
|
+
}
|
|
19
|
+
public get rendered() {
|
|
20
|
+
return this._rendered;
|
|
21
|
+
}
|
|
18
22
|
|
|
19
23
|
public constructor(element: HTMLElement) {
|
|
20
24
|
this._element = element;
|
|
@@ -15,8 +15,12 @@ class VirtualElementProvider implements ElementProvider {
|
|
|
15
15
|
private _flicking: Flicking;
|
|
16
16
|
private _panel: VirtualPanel;
|
|
17
17
|
|
|
18
|
-
public get element() {
|
|
19
|
-
|
|
18
|
+
public get element() {
|
|
19
|
+
return this._virtualElement.nativeElement;
|
|
20
|
+
}
|
|
21
|
+
public get rendered() {
|
|
22
|
+
return this._virtualElement.visible;
|
|
23
|
+
}
|
|
20
24
|
|
|
21
25
|
private get _virtualElement() {
|
|
22
26
|
const flicking = this._flicking;
|
|
@@ -6,11 +6,6 @@ import ElementProvider from "./ElementProvider";
|
|
|
6
6
|
import VanillaElementProvider from "./VanillaElementProvider";
|
|
7
7
|
import VirtualElementProvider from "./VirtualElementProvider";
|
|
8
8
|
|
|
9
|
-
export {
|
|
10
|
-
VanillaElementProvider,
|
|
11
|
-
VirtualElementProvider
|
|
12
|
-
};
|
|
9
|
+
export { VanillaElementProvider, VirtualElementProvider };
|
|
13
10
|
|
|
14
|
-
export type {
|
|
15
|
-
ElementProvider
|
|
16
|
-
};
|
|
11
|
+
export type { ElementProvider };
|
|
@@ -7,10 +7,8 @@ import { setPrototypeOf } from "../utils";
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Special type of known error that {@link Flicking} throws.
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
12
|
-
* @property {string} message Error message<ko>에러 메시지</ko>
|
|
13
|
-
* @see {@link ERROR_CODE ERROR_CODE}
|
|
10
|
+
* @remarks
|
|
11
|
+
* see {@link FlickingErrors} for possible error codes and explantaion
|
|
14
12
|
* @example
|
|
15
13
|
* ```ts
|
|
16
14
|
* import Flicking, { FlickingError, ERROR_CODES } from "@egjs/flicking";
|
|
@@ -18,7 +16,7 @@ import { setPrototypeOf } from "../utils";
|
|
|
18
16
|
* const flicking = new Flicking(".flicking-viewport")
|
|
19
17
|
* } catch (e) {
|
|
20
18
|
* if (e instanceof FlickingError && e.code === ERROR_CODES.ELEMENT_NOT_FOUND) {
|
|
21
|
-
* console.error(
|
|
19
|
+
* console.error(e.message)
|
|
22
20
|
* }
|
|
23
21
|
* }
|
|
24
22
|
* ```
|
|
@@ -27,8 +25,8 @@ class FlickingError extends Error {
|
|
|
27
25
|
public code: number;
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
|
-
* @param message Error message
|
|
31
|
-
* @param code Error code
|
|
28
|
+
* @param message - Error message
|
|
29
|
+
* @param code - Error code
|
|
32
30
|
*/
|
|
33
31
|
public constructor(message: string, code: number) {
|
|
34
32
|
super(message);
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
3
|
+
* egjs projects are licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
6
|
+
|
|
7
|
+
import type { FlickingErrors } from "./types";
|
|
8
|
+
|
|
9
|
+
type ErrorKey = keyof FlickingErrors;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal error catalog containing all error information.
|
|
13
|
+
* @remarks
|
|
14
|
+
* This is the single source of truth for all error codes and messages.
|
|
15
|
+
* Use {@link ERROR_CODE} and {@link MESSAGE} exports for public access.
|
|
16
|
+
* @privateRemarks
|
|
17
|
+
* ## How to add a new error code
|
|
18
|
+
*
|
|
19
|
+
* 1. **Add to this `errors` object:**
|
|
20
|
+
* ```typescript
|
|
21
|
+
* NEW_ERROR_NAME: {
|
|
22
|
+
* code: 15, // next available number
|
|
23
|
+
* message: "Error message" // or function for parameterized messages
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* 2. **Document in FlickingErrors** (types.ts):
|
|
28
|
+
* - Add property with same name and type signature
|
|
29
|
+
* - Write comprehensive TSDoc with @remarks, @example, @see tags
|
|
30
|
+
* - Include: description, common causes, solutions, wrong/correct examples
|
|
31
|
+
*
|
|
32
|
+
* 3. **Verify:**
|
|
33
|
+
* - `pnpm build` - check TypeScript compilation
|
|
34
|
+
* - `pnpm api-docs:docusaurus` - generate documentation
|
|
35
|
+
* - Check packages/docs/docs/api/interfaces/FlickingErrors.mdx
|
|
36
|
+
*
|
|
37
|
+
* Note: `CODE` and `MESSAGE` exports are auto-generated via reduce, no manual updates needed.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
const errors: FlickingErrors = {
|
|
41
|
+
WRONG_TYPE: {
|
|
42
|
+
code: 0,
|
|
43
|
+
message: (wrongVal, correctTypes) =>
|
|
44
|
+
`${wrongVal}(${typeof wrongVal}) is not a ${correctTypes.map(type => `"${type}"`).join(" or ")}.`
|
|
45
|
+
},
|
|
46
|
+
ELEMENT_NOT_FOUND: {
|
|
47
|
+
code: 1,
|
|
48
|
+
message: selector => `Element with selector "${selector}" not found.`
|
|
49
|
+
},
|
|
50
|
+
VAL_MUST_NOT_NULL: {
|
|
51
|
+
code: 2,
|
|
52
|
+
message: (val, name) => `${name} should be provided. Given: ${val}`
|
|
53
|
+
},
|
|
54
|
+
NOT_ATTACHED_TO_FLICKING: {
|
|
55
|
+
code: 3,
|
|
56
|
+
message: 'This module is not attached to the Flicking instance. "init()" should be called first.'
|
|
57
|
+
},
|
|
58
|
+
WRONG_OPTION: {
|
|
59
|
+
code: 4,
|
|
60
|
+
message: (optionName, val) => `Option "${optionName}" is not in correct format, given: ${val}`
|
|
61
|
+
},
|
|
62
|
+
INDEX_OUT_OF_RANGE: {
|
|
63
|
+
code: 5,
|
|
64
|
+
message: (val, min, max) => `Index "${val}" is out of range: should be between ${min} and ${max}.`
|
|
65
|
+
},
|
|
66
|
+
POSITION_NOT_REACHABLE: {
|
|
67
|
+
code: 6,
|
|
68
|
+
message: position => `Position "${position}" is not reachable.`
|
|
69
|
+
},
|
|
70
|
+
TRANSFORM_NOT_SUPPORTED: {
|
|
71
|
+
code: 7,
|
|
72
|
+
message: "Browser does not support CSS transform."
|
|
73
|
+
},
|
|
74
|
+
STOP_CALLED_BY_USER: {
|
|
75
|
+
code: 8,
|
|
76
|
+
message: "Event stop() is called by user."
|
|
77
|
+
},
|
|
78
|
+
ANIMATION_INTERRUPTED: {
|
|
79
|
+
code: 9,
|
|
80
|
+
message: "Animation is interrupted by user input."
|
|
81
|
+
},
|
|
82
|
+
ANIMATION_ALREADY_PLAYING: {
|
|
83
|
+
code: 10,
|
|
84
|
+
message: "Animation is already playing."
|
|
85
|
+
},
|
|
86
|
+
NOT_ALLOWED_IN_FRAMEWORK: {
|
|
87
|
+
code: 11,
|
|
88
|
+
message: "This behavior is not allowed in the frameworks like React, Vue, or Angular."
|
|
89
|
+
},
|
|
90
|
+
NOT_INITIALIZED: {
|
|
91
|
+
code: 12,
|
|
92
|
+
message: "Flicking is not initialized yet, call init() first."
|
|
93
|
+
},
|
|
94
|
+
NO_ACTIVE: {
|
|
95
|
+
code: 13,
|
|
96
|
+
message: "There's no active panel that Flicking has selected. This may be due to the absence of any panels."
|
|
97
|
+
},
|
|
98
|
+
NOT_ALLOWED_IN_VIRTUAL: {
|
|
99
|
+
code: 14,
|
|
100
|
+
message: "This behavior is not allowed when the virtual option is enabled"
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Error codes of {@link FlickingError}.
|
|
106
|
+
* @remarks
|
|
107
|
+
* Each error code represents a specific error condition that can occur during Flicking's lifecycle.
|
|
108
|
+
* Use these codes to identify and handle errors programmatically.
|
|
109
|
+
*
|
|
110
|
+
* For detailed documentation of each error code, see {@link FlickingErrors}.
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* import {FlickingError, ERROR_CODE} from "@egjs/flicking";
|
|
114
|
+
*
|
|
115
|
+
* try {
|
|
116
|
+
* flicking.moveTo(999);
|
|
117
|
+
* } catch (err) {
|
|
118
|
+
* if (err instancof FlickingError && err.code === ERROR_CODE.INDEX_OUT_OF_RANGE) {
|
|
119
|
+
* console.log(err.message);
|
|
120
|
+
* }
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
* @public
|
|
124
|
+
* @see {@link FlickingErrors} for detailed documentation of each error code
|
|
125
|
+
*/
|
|
126
|
+
export const CODE = (Object.keys(errors) as ErrorKey[]).reduce(
|
|
127
|
+
(acc, key) => {
|
|
128
|
+
acc[key] = errors[key].code;
|
|
129
|
+
return acc;
|
|
130
|
+
},
|
|
131
|
+
{} as Record<ErrorKey, number>
|
|
132
|
+
) as { [K in ErrorKey]: FlickingErrors[K]["code"] };
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Error message generators for {@link FlickingError}.
|
|
136
|
+
* @remarks
|
|
137
|
+
* These functions generate human-readable error messages for each error code.
|
|
138
|
+
* Used internally by Flicking to create {@link FlickingError} instances with
|
|
139
|
+
* contextual information.
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
export const MESSAGE = (Object.keys(errors) as ErrorKey[]).reduce(
|
|
143
|
+
(acc, key) => {
|
|
144
|
+
acc[key] = errors[key].message;
|
|
145
|
+
return acc;
|
|
146
|
+
},
|
|
147
|
+
{} as Record<string, any>
|
|
148
|
+
) as { [K in ErrorKey]: FlickingErrors[K]["message"] };
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Alias for {@link CODE}.
|
|
152
|
+
* @remarks
|
|
153
|
+
* Exported as `ERROR_CODE` for semantic clarity when importing.
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* import { ERROR_CODE } from "@egjs/flicking";
|
|
157
|
+
*
|
|
158
|
+
* if (err.code === ERROR_CODE.INDEX_OUT_OF_RANGE) {
|
|
159
|
+
* // Handle index error
|
|
160
|
+
* }
|
|
161
|
+
* ```
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
export { CODE as ERROR_CODE };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
3
|
+
* egjs projects are licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ERROR_CODE } from "./codes";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Error codes that may be thrown during panel movement operations.
|
|
10
|
+
* @remarks
|
|
11
|
+
* These errors can occur when using navigation methods like {@link Flicking.prev},
|
|
12
|
+
* {@link Flicking.next}, or {@link Flicking.moveTo}.
|
|
13
|
+
*
|
|
14
|
+
* Common scenarios:
|
|
15
|
+
*
|
|
16
|
+
* - `NOT_INITIALIZED`: Attempting to navigate before Flicking is ready
|
|
17
|
+
*
|
|
18
|
+
* - `INDEX_OUT_OF_RANGE`: Target panel index doesn't exist
|
|
19
|
+
*
|
|
20
|
+
* - `POSITION_NOT_REACHABLE`: Target camera position is invalid
|
|
21
|
+
*
|
|
22
|
+
* - `ANIMATION_INTERRUPTED`: User interaction during animation
|
|
23
|
+
*
|
|
24
|
+
* - `ANIMATION_ALREADY_PLAYING`: Starting new animation while one is in progress
|
|
25
|
+
*
|
|
26
|
+
* - `STOP_CALLED_BY_USER`: User prevented navigation via `event.stop()`
|
|
27
|
+
*
|
|
28
|
+
* - `NO_ACTIVE`: No panels available to navigate
|
|
29
|
+
*/
|
|
30
|
+
export type MovementErrors =
|
|
31
|
+
| typeof ERROR_CODE.NOT_INITIALIZED
|
|
32
|
+
| typeof ERROR_CODE.INDEX_OUT_OF_RANGE
|
|
33
|
+
| typeof ERROR_CODE.POSITION_NOT_REACHABLE
|
|
34
|
+
| typeof ERROR_CODE.ANIMATION_INTERRUPTED
|
|
35
|
+
| typeof ERROR_CODE.ANIMATION_ALREADY_PLAYING
|
|
36
|
+
| typeof ERROR_CODE.STOP_CALLED_BY_USER
|
|
37
|
+
| typeof ERROR_CODE.NO_ACTIVE;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Error codes that may be thrown when manipulating the DOM.
|
|
41
|
+
* @remarks
|
|
42
|
+
* These errors can occur when using DOM manipulation methods like
|
|
43
|
+
* {@link Flicking.insert}, {@link Flicking.append}, {@link Flicking.prepend},
|
|
44
|
+
* {@link Flicking.replace}, or {@link Flicking.remove}.
|
|
45
|
+
*
|
|
46
|
+
* Common scenarios:
|
|
47
|
+
*
|
|
48
|
+
* - `NOT_ATTACHED_TO_FLICKING`: Component not properly initialized
|
|
49
|
+
*
|
|
50
|
+
* - `ELEMENT_NOT_FOUND`: Invalid CSS selector or element doesn't exist
|
|
51
|
+
*
|
|
52
|
+
* - `VAL_MUST_NOT_NULL`: Required parameter is null/undefined
|
|
53
|
+
*
|
|
54
|
+
* - `WRONG_TYPE`: Invalid parameter type
|
|
55
|
+
*
|
|
56
|
+
* - `INDEX_OUT_OF_RANGE`: Target index doesn't exist
|
|
57
|
+
*
|
|
58
|
+
* - `NOT_ALLOWED_IN_FRAMEWORK`: Using DOM methods in React/Vue/Angular
|
|
59
|
+
*
|
|
60
|
+
* - `NOT_ALLOWED_IN_VIRTUAL`: Using DOM methods with virtual mode enabled
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
export type DOMManipulationErrors =
|
|
64
|
+
| typeof ERROR_CODE.NOT_ATTACHED_TO_FLICKING
|
|
65
|
+
| typeof ERROR_CODE.ELEMENT_NOT_FOUND
|
|
66
|
+
| typeof ERROR_CODE.VAL_MUST_NOT_NULL
|
|
67
|
+
| typeof ERROR_CODE.WRONG_TYPE
|
|
68
|
+
| typeof ERROR_CODE.INDEX_OUT_OF_RANGE
|
|
69
|
+
| typeof ERROR_CODE.NOT_ALLOWED_IN_FRAMEWORK
|
|
70
|
+
| typeof ERROR_CODE.NOT_ALLOWED_IN_VIRTUAL;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Error codes that may be thrown during Flicking initialization.
|
|
74
|
+
* @remarks
|
|
75
|
+
* These errors can occur when creating a new Flicking instance or calling {@link Flicking.init}.
|
|
76
|
+
*
|
|
77
|
+
* Common scenarios:
|
|
78
|
+
*
|
|
79
|
+
* - `ELEMENT_NOT_FOUND`: Viewport element doesn't exist in DOM
|
|
80
|
+
*
|
|
81
|
+
* - `WRONG_OPTION`: Invalid configuration option value
|
|
82
|
+
*
|
|
83
|
+
* - `TRANSFORM_NOT_SUPPORTED`: Browser doesn't support CSS transforms (IE8 and below)
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export type InitializationErrors =
|
|
87
|
+
| typeof ERROR_CODE.ELEMENT_NOT_FOUND
|
|
88
|
+
| typeof ERROR_CODE.WRONG_OPTION
|
|
89
|
+
| typeof ERROR_CODE.TRANSFORM_NOT_SUPPORTED;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Error codes that may be thrown during animation updates.
|
|
93
|
+
* @remarks
|
|
94
|
+
* These errors can occur when calling {@link Flicking.update} to manually update
|
|
95
|
+
* the animation state.
|
|
96
|
+
*
|
|
97
|
+
* Common scenarios:
|
|
98
|
+
*
|
|
99
|
+
* - `NOT_INITIALIZED`: Calling update before Flicking is ready
|
|
100
|
+
*
|
|
101
|
+
* - `ANIMATION_INTERRUPTED`: User interrupted the animation during update
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export type AnimationUpdateErrors = typeof ERROR_CODE.NOT_INITIALIZED | typeof ERROR_CODE.ANIMATION_INTERRUPTED;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Error codes that may be thrown when restoring Flicking status.
|
|
108
|
+
* @remarks
|
|
109
|
+
* These errors can occur when using {@link Flicking.setStatus} to restore
|
|
110
|
+
* a previously saved status (from {@link Flicking.getStatus}).
|
|
111
|
+
*
|
|
112
|
+
* Common scenarios:
|
|
113
|
+
*
|
|
114
|
+
* - `NOT_INITIALIZED`: Attempting to restore before initialization
|
|
115
|
+
*
|
|
116
|
+
* - `INDEX_OUT_OF_RANGE`: Saved status references non-existent panel
|
|
117
|
+
*
|
|
118
|
+
* - `POSITION_NOT_REACHABLE`: Saved position is no longer valid
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
export type StatusRestoreErrors =
|
|
122
|
+
| typeof ERROR_CODE.NOT_INITIALIZED
|
|
123
|
+
| typeof ERROR_CODE.INDEX_OUT_OF_RANGE
|
|
124
|
+
| typeof ERROR_CODE.POSITION_NOT_REACHABLE;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
3
|
+
* egjs projects are licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { CODE, ERROR_CODE, MESSAGE } from "./codes";
|
|
7
|
+
export { default as FlickingError } from "./FlickingError";
|
|
8
|
+
export * from "./groups";
|
|
9
|
+
export * from "./types";
|