@egjs/flicking 4.15.0 → 4.16.0-beta.1
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
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { OnAnimationEnd, OnChange, OnFinish, OnHold, OnRelease } from "@egjs/axes";
|
|
2
|
+
import Panel from "../../core/panel/Panel";
|
|
3
|
+
import Flicking from "../../Flicking";
|
|
4
|
+
export declare enum STATE_TYPE {
|
|
5
|
+
IDLE = 0,
|
|
6
|
+
HOLDING = 1,
|
|
7
|
+
DRAGGING = 2,
|
|
8
|
+
ANIMATING = 3,
|
|
9
|
+
DISABLED = 4
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Event context for State event handlers
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export interface StateContext<T> {
|
|
16
|
+
/** An instance of Flicking */
|
|
17
|
+
flicking: Flicking;
|
|
18
|
+
/** An Axes event */
|
|
19
|
+
axesEvent: T;
|
|
20
|
+
/** A function for changing current state to other state */
|
|
21
|
+
transitTo: (nextState: STATE_TYPE) => State;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A component that shows the current status of the user input or the animation
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
declare abstract class State {
|
|
28
|
+
/**
|
|
29
|
+
* Whether user is clicking or touching
|
|
30
|
+
* @readonly
|
|
31
|
+
*/
|
|
32
|
+
abstract readonly holding: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether Flicking's animating
|
|
35
|
+
* @readonly
|
|
36
|
+
*/
|
|
37
|
+
abstract readonly animating: boolean;
|
|
38
|
+
protected _delta: number;
|
|
39
|
+
protected _targetPanel: Panel | null;
|
|
40
|
+
/**
|
|
41
|
+
* A sum of delta values of change events from the last hold event of Axes
|
|
42
|
+
* @readonly
|
|
43
|
+
*/
|
|
44
|
+
get delta(): number;
|
|
45
|
+
/**
|
|
46
|
+
* A panel to set as {@link Control.activePanel} after the animation is finished
|
|
47
|
+
* @readonly
|
|
48
|
+
*/
|
|
49
|
+
get targetPanel(): Panel | null;
|
|
50
|
+
set targetPanel(val: Panel | null);
|
|
51
|
+
/**
|
|
52
|
+
* An callback which is called when state has changed to this state
|
|
53
|
+
* @param prevState - An previous state
|
|
54
|
+
*/
|
|
55
|
+
onEnter(prevState: State): void;
|
|
56
|
+
/**
|
|
57
|
+
* An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-hold | hold} event
|
|
58
|
+
* @param ctx - {@link StateContext}
|
|
59
|
+
*/
|
|
60
|
+
onHold(ctx: StateContext<OnHold>): void;
|
|
61
|
+
/**
|
|
62
|
+
* An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-change | change} event
|
|
63
|
+
* @param ctx - {@link StateContext}
|
|
64
|
+
*/
|
|
65
|
+
onChange(ctx: StateContext<OnChange>): void;
|
|
66
|
+
/**
|
|
67
|
+
* An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-release | release} event
|
|
68
|
+
* @param ctx - {@link StateContext}
|
|
69
|
+
*/
|
|
70
|
+
onRelease(ctx: StateContext<OnRelease>): void;
|
|
71
|
+
/**
|
|
72
|
+
* An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-animationEnd | animationEnd} event
|
|
73
|
+
* @param ctx - {@link StateContext}
|
|
74
|
+
*/
|
|
75
|
+
onAnimationEnd(ctx: StateContext<OnAnimationEnd>): void;
|
|
76
|
+
/**
|
|
77
|
+
* An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-finish | finish} event
|
|
78
|
+
* @param ctx - {@link StateContext}
|
|
79
|
+
*/
|
|
80
|
+
onFinish(ctx: StateContext<OnFinish>): void;
|
|
81
|
+
/**
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
protected _moveToChangedPosition(ctx: StateContext<OnChange>): void;
|
|
85
|
+
}
|
|
86
|
+
export default State;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Panel from "./panel/Panel";
|
|
2
|
+
/**
|
|
3
|
+
* Options for creating an AnchorPoint
|
|
4
|
+
*/
|
|
5
|
+
export interface AnchorPointOptions {
|
|
6
|
+
/** Index of AnchorPoint */
|
|
7
|
+
index: number;
|
|
8
|
+
/** Position of AnchorPoint */
|
|
9
|
+
position: number;
|
|
10
|
+
/** A {@link Panel} instance AnchorPoint is referencing to */
|
|
11
|
+
panel: Panel;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A data component that has actual position where the camera should be stopped at
|
|
15
|
+
*/
|
|
16
|
+
declare class AnchorPoint {
|
|
17
|
+
private _index;
|
|
18
|
+
private _pos;
|
|
19
|
+
private _panel;
|
|
20
|
+
/**
|
|
21
|
+
* Index of AnchorPoint
|
|
22
|
+
* @readonly
|
|
23
|
+
*/
|
|
24
|
+
get index(): number;
|
|
25
|
+
/**
|
|
26
|
+
* Position of AnchorPoint
|
|
27
|
+
* @readonly
|
|
28
|
+
*/
|
|
29
|
+
get position(): number;
|
|
30
|
+
/**
|
|
31
|
+
* A {@link Panel} instance AnchorPoint is referencing to
|
|
32
|
+
* @readonly
|
|
33
|
+
*/
|
|
34
|
+
get panel(): Panel;
|
|
35
|
+
/**
|
|
36
|
+
* @param options - {@link AnchorPointOptions}
|
|
37
|
+
*/
|
|
38
|
+
constructor(options: AnchorPointOptions);
|
|
39
|
+
}
|
|
40
|
+
export default AnchorPoint;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import Flicking from "../Flicking";
|
|
2
|
+
/**
|
|
3
|
+
* A component that detects size change and trigger resize method when the autoResize option is used
|
|
4
|
+
*/
|
|
2
5
|
declare class AutoResizer {
|
|
3
6
|
private _flicking;
|
|
4
7
|
private _enabled;
|
|
@@ -6,6 +9,9 @@ declare class AutoResizer {
|
|
|
6
9
|
private _resizeTimer;
|
|
7
10
|
private _maxResizeDebounceTimer;
|
|
8
11
|
get enabled(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* @param flicking
|
|
14
|
+
*/
|
|
9
15
|
constructor(flicking: Flicking);
|
|
10
16
|
enable(): this;
|
|
11
17
|
observePanels(): this;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import Flicking from "../Flicking";
|
|
2
|
+
import { SetSizeParams } from "../types/params";
|
|
3
|
+
export interface ViewportPadding {
|
|
4
|
+
/** CSS `padding-left` */
|
|
5
|
+
left: number;
|
|
6
|
+
/** CSS `padding-right` */
|
|
7
|
+
right: number;
|
|
8
|
+
/** CSS `padding-top` */
|
|
9
|
+
top: number;
|
|
10
|
+
/** CSS `padding-bottom` */
|
|
11
|
+
bottom: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A component that manages viewport size
|
|
15
|
+
*/
|
|
16
|
+
declare class Viewport {
|
|
17
|
+
private _flicking;
|
|
18
|
+
private _el;
|
|
19
|
+
private _width;
|
|
20
|
+
private _height;
|
|
21
|
+
private _isBorderBoxSizing;
|
|
22
|
+
private _padding;
|
|
23
|
+
/**
|
|
24
|
+
* A viewport(root) element
|
|
25
|
+
* @readonly
|
|
26
|
+
*/
|
|
27
|
+
get element(): HTMLElement;
|
|
28
|
+
/**
|
|
29
|
+
* Viewport width, without paddings
|
|
30
|
+
* @readonly
|
|
31
|
+
*/
|
|
32
|
+
get width(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Viewport height, without paddings
|
|
35
|
+
* @readonly
|
|
36
|
+
*/
|
|
37
|
+
get height(): number;
|
|
38
|
+
/**
|
|
39
|
+
* Viewport paddings
|
|
40
|
+
* @readonly
|
|
41
|
+
*/
|
|
42
|
+
get padding(): ViewportPadding;
|
|
43
|
+
/**
|
|
44
|
+
* @param flicking - Flicking instance
|
|
45
|
+
* @param el - A viewport element
|
|
46
|
+
*/
|
|
47
|
+
constructor(flicking: Flicking, el: HTMLElement);
|
|
48
|
+
/**
|
|
49
|
+
* Change viewport's size.
|
|
50
|
+
* @remarks
|
|
51
|
+
* This will change the actual size of `.flicking-viewport` element by changing its CSS width/height property
|
|
52
|
+
* @param size - {@link SetSizeParams}
|
|
53
|
+
*/
|
|
54
|
+
setSize(size: SetSizeParams): void;
|
|
55
|
+
/**
|
|
56
|
+
* Update width/height to the current viewport element's size
|
|
57
|
+
*/
|
|
58
|
+
resize(): void;
|
|
59
|
+
}
|
|
60
|
+
export default Viewport;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import Flicking from "../Flicking";
|
|
2
|
+
import VirtualPanel from "./panel/VirtualPanel";
|
|
3
|
+
export declare type PanelRenderCallback = ((
|
|
4
|
+
/** Virtual panel to render */
|
|
5
|
+
panel: VirtualPanel,
|
|
6
|
+
/** Index of the panel */
|
|
7
|
+
index: number) => string) | (() => string);
|
|
8
|
+
export interface VirtualOptions {
|
|
9
|
+
renderPanel: PanelRenderCallback;
|
|
10
|
+
initialPanelCount: number;
|
|
11
|
+
cache?: boolean;
|
|
12
|
+
panelClass?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A manager class to add / remove virtual panels
|
|
16
|
+
*/
|
|
17
|
+
declare class VirtualManager {
|
|
18
|
+
private _flicking;
|
|
19
|
+
private _renderPanel;
|
|
20
|
+
private _initialPanelCount;
|
|
21
|
+
private _cache;
|
|
22
|
+
private _panelClass;
|
|
23
|
+
private _elements;
|
|
24
|
+
get elements(): {
|
|
25
|
+
nativeElement: HTMLElement;
|
|
26
|
+
visible: boolean;
|
|
27
|
+
}[];
|
|
28
|
+
/**
|
|
29
|
+
* A rendering function for the panel element's innerHTML
|
|
30
|
+
*/
|
|
31
|
+
get renderPanel(): PanelRenderCallback;
|
|
32
|
+
/**
|
|
33
|
+
* Initial panel count to render
|
|
34
|
+
* @readonly
|
|
35
|
+
* @defaultValue -1
|
|
36
|
+
*/
|
|
37
|
+
get initialPanelCount(): number;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to cache rendered panel's innerHTML
|
|
40
|
+
* @defaultValue false
|
|
41
|
+
*/
|
|
42
|
+
get cache(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The class name that will be applied to rendered panel elements
|
|
45
|
+
* @defaultValue "flicking-panel"
|
|
46
|
+
*/
|
|
47
|
+
get panelClass(): string;
|
|
48
|
+
set renderPanel(val: VirtualOptions["renderPanel"]);
|
|
49
|
+
set cache(val: NonNullable<VirtualOptions["cache"]>);
|
|
50
|
+
set panelClass(val: NonNullable<VirtualOptions["panelClass"]>);
|
|
51
|
+
constructor(flicking: Flicking, options: VirtualOptions | null);
|
|
52
|
+
init(): void;
|
|
53
|
+
show(index: number): void;
|
|
54
|
+
hide(index: number): void;
|
|
55
|
+
/**
|
|
56
|
+
* Add new virtual panels at the end of the list
|
|
57
|
+
* @param count - The number of panels to add
|
|
58
|
+
* @returns The new panels added
|
|
59
|
+
*/
|
|
60
|
+
append(count?: number): VirtualPanel[];
|
|
61
|
+
/**
|
|
62
|
+
* Add new virtual panels at the start of the list
|
|
63
|
+
* @param count - The number of panels to add
|
|
64
|
+
* @returns The new panels added
|
|
65
|
+
*/
|
|
66
|
+
prepend(count?: number): VirtualPanel[];
|
|
67
|
+
/**
|
|
68
|
+
* Add new virtual panels at the given index
|
|
69
|
+
* @param count - The number of panels to add
|
|
70
|
+
* @returns The new panels added
|
|
71
|
+
*/
|
|
72
|
+
insert(index: number, count?: number): VirtualPanel[];
|
|
73
|
+
/**
|
|
74
|
+
* Remove panels at the given index
|
|
75
|
+
* @param count - The number of panels to remove
|
|
76
|
+
* @returns The panels removed
|
|
77
|
+
*/
|
|
78
|
+
remove(index: number, count: number): VirtualPanel[];
|
|
79
|
+
/**
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
private _initVirtualElements;
|
|
83
|
+
}
|
|
84
|
+
export default VirtualManager;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import AnchorPoint from "./AnchorPoint";
|
|
2
|
+
import Viewport, { ViewportPadding } from "./Viewport";
|
|
3
|
+
import VirtualManager, { PanelRenderCallback, VirtualOptions } from "./VirtualManager";
|
|
4
|
+
export { Viewport, AnchorPoint, VirtualManager };
|
|
5
|
+
export type { ViewportPadding, VirtualOptions, PanelRenderCallback };
|
|
6
|
+
export * from "./panel";
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { ALIGN, DIRECTION } from "../../constants/values";
|
|
2
|
+
import Flicking from "../../Flicking";
|
|
3
|
+
import { LiteralUnion, ValueOf } from "../../types/internal";
|
|
4
|
+
import { SetSizeParams } from "../../types/params";
|
|
5
|
+
import ElementProvider from "./provider/ElementProvider";
|
|
6
|
+
export interface PanelOptions {
|
|
7
|
+
/** An initial index of the panel */
|
|
8
|
+
index: number;
|
|
9
|
+
/** An initial {@link Flicking.align | align} value of the panel */
|
|
10
|
+
align: LiteralUnion<ValueOf<typeof ALIGN>> | number;
|
|
11
|
+
/** The Flicking instance that this panel belongs to */
|
|
12
|
+
flicking: Flicking;
|
|
13
|
+
/** A provider instance that returns the actual html element */
|
|
14
|
+
elementProvider: ElementProvider;
|
|
15
|
+
}
|
|
16
|
+
export interface PanelMarginInfo {
|
|
17
|
+
/** CSS `margin-left` when the {@link Flicking.horizontal | horizontal} is `true`, and `margin-top` else */
|
|
18
|
+
prev: number;
|
|
19
|
+
/** CSS `margin-right` when the {@link Flicking.horizontal | horizontal} is `true`, and `margin-bottom` else */
|
|
20
|
+
next: number;
|
|
21
|
+
}
|
|
22
|
+
export interface PanelBoundingBoxRange {
|
|
23
|
+
/** Bounding box's left({@link Flicking.horizontal | horizontal}: true) / top({@link Flicking.horizontal | horizontal}: false) */
|
|
24
|
+
min: number;
|
|
25
|
+
/** Bounding box's right({@link Flicking.horizontal | horizontal}: true) / bottom({@link Flicking.horizontal | horizontal}: false) */
|
|
26
|
+
max: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A slide data component that holds information of a single HTMLElement
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
declare class Panel {
|
|
33
|
+
protected _flicking: Flicking;
|
|
34
|
+
protected _elProvider: ElementProvider;
|
|
35
|
+
protected _index: number;
|
|
36
|
+
protected _pos: number;
|
|
37
|
+
protected _size: number;
|
|
38
|
+
protected _height: number;
|
|
39
|
+
protected _margin: PanelMarginInfo;
|
|
40
|
+
protected _alignPos: number;
|
|
41
|
+
protected _rendered: boolean;
|
|
42
|
+
protected _removed: boolean;
|
|
43
|
+
protected _loading: boolean;
|
|
44
|
+
protected _toggleDirection: ValueOf<typeof DIRECTION>;
|
|
45
|
+
protected _toggled: boolean;
|
|
46
|
+
protected _togglePosition: number;
|
|
47
|
+
protected _align: PanelOptions["align"];
|
|
48
|
+
/**
|
|
49
|
+
* `HTMLElement` that panel's referencing
|
|
50
|
+
* @readonly
|
|
51
|
+
*/
|
|
52
|
+
get element(): HTMLElement;
|
|
53
|
+
/**
|
|
54
|
+
* @internal
|
|
55
|
+
* @readonly
|
|
56
|
+
*/
|
|
57
|
+
get elementProvider(): ElementProvider;
|
|
58
|
+
/**
|
|
59
|
+
* Index of the panel
|
|
60
|
+
* @readonly
|
|
61
|
+
*/
|
|
62
|
+
get index(): number;
|
|
63
|
+
/**
|
|
64
|
+
* Position of the panel, including {@link Panel.alignPosition | alignPosition}
|
|
65
|
+
* @readonly
|
|
66
|
+
*/
|
|
67
|
+
get position(): number;
|
|
68
|
+
/**
|
|
69
|
+
* Cached size of the panel element
|
|
70
|
+
* @remarks
|
|
71
|
+
* This is equal to {@link Panel.element | element}'s `offsetWidth` if {@link Flicking.horizontal | horizontal} is `true`, and `offsetHeight` else
|
|
72
|
+
* @readonly
|
|
73
|
+
*/
|
|
74
|
+
get size(): number;
|
|
75
|
+
/**
|
|
76
|
+
* Panel's size including CSS `margin`
|
|
77
|
+
* @remarks
|
|
78
|
+
* This value includes {@link Panel.element | element}'s margin left/right if {@link Flicking.horizontal | horizontal} is `true`, and margin top/bottom else
|
|
79
|
+
* @readonly
|
|
80
|
+
*/
|
|
81
|
+
get sizeIncludingMargin(): number;
|
|
82
|
+
/**
|
|
83
|
+
* Height of the panel element
|
|
84
|
+
* @readonly
|
|
85
|
+
*/
|
|
86
|
+
get height(): number;
|
|
87
|
+
/**
|
|
88
|
+
* Cached CSS `margin` value of the panel element
|
|
89
|
+
* @readonly
|
|
90
|
+
*/
|
|
91
|
+
get margin(): PanelMarginInfo;
|
|
92
|
+
/**
|
|
93
|
+
* Align position inside the panel where {@link Camera}'s {@link Camera.alignPosition | alignPosition} inside viewport should be located at
|
|
94
|
+
* @readonly
|
|
95
|
+
*/
|
|
96
|
+
get alignPosition(): number;
|
|
97
|
+
/**
|
|
98
|
+
* A value indicating whether the panel's {@link Flicking.remove | remove}d
|
|
99
|
+
* @readonly
|
|
100
|
+
*/
|
|
101
|
+
get removed(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* A value indicating whether the panel's element is being rendered on the screen
|
|
104
|
+
* @readonly
|
|
105
|
+
*/
|
|
106
|
+
get rendered(): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* A value indicating whether the panel's image/video is not loaded and waiting for resize
|
|
109
|
+
* @readonly
|
|
110
|
+
*/
|
|
111
|
+
get loading(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Panel element's range of the bounding box
|
|
114
|
+
* @readonly
|
|
115
|
+
*/
|
|
116
|
+
get range(): PanelBoundingBoxRange;
|
|
117
|
+
/**
|
|
118
|
+
* A value indicating whether the panel's position is toggled by circular behavior
|
|
119
|
+
* @readonly
|
|
120
|
+
*/
|
|
121
|
+
get toggled(): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* A direction where the panel's position is toggled
|
|
124
|
+
* @readonly
|
|
125
|
+
*/
|
|
126
|
+
get toggleDirection(): ValueOf<typeof DIRECTION>;
|
|
127
|
+
/**
|
|
128
|
+
* Actual position offset determined by {@link Panel.order}
|
|
129
|
+
* @readonly
|
|
130
|
+
*/
|
|
131
|
+
get offset(): number;
|
|
132
|
+
/**
|
|
133
|
+
* Progress of movement between previous or next panel relative to current panel
|
|
134
|
+
* @readonly
|
|
135
|
+
*/
|
|
136
|
+
get progress(): number;
|
|
137
|
+
/**
|
|
138
|
+
* Progress of movement between points that panel is completely invisible outside of viewport(prev direction: -1, selected point: 0, next direction: 1)
|
|
139
|
+
* @readonly
|
|
140
|
+
*/
|
|
141
|
+
get outsetProgress(): number;
|
|
142
|
+
/**
|
|
143
|
+
* Percentage of area where panel is visible in the viewport
|
|
144
|
+
* @readonly
|
|
145
|
+
*/
|
|
146
|
+
get visibleRatio(): number;
|
|
147
|
+
set loading(val: boolean);
|
|
148
|
+
/**
|
|
149
|
+
* A value indicating where the {@link Panel.alignPosition | alignPosition} should be located at inside the panel element
|
|
150
|
+
*/
|
|
151
|
+
get align(): PanelOptions["align"];
|
|
152
|
+
set align(val: PanelOptions["align"]);
|
|
153
|
+
/**
|
|
154
|
+
* Creates a new Panel instance
|
|
155
|
+
* @param panelOptions - Options for creating the panel
|
|
156
|
+
*/
|
|
157
|
+
constructor(panelOptions: PanelOptions);
|
|
158
|
+
/**
|
|
159
|
+
* @internal
|
|
160
|
+
* @privateRemarks
|
|
161
|
+
* Marks this panel to be rendered on the camera element.
|
|
162
|
+
*/
|
|
163
|
+
markForShow(): void;
|
|
164
|
+
/**
|
|
165
|
+
* @internal
|
|
166
|
+
* @privateRemarks
|
|
167
|
+
* Marks this panel to be hidden from the camera element.
|
|
168
|
+
*/
|
|
169
|
+
markForHide(): void;
|
|
170
|
+
/**
|
|
171
|
+
* Update size of the panel
|
|
172
|
+
* @remarks
|
|
173
|
+
* This method recalculates the panel's size, margin, and position based on the current DOM state.
|
|
174
|
+
* @param cached - Predefined cached size of the panel
|
|
175
|
+
* @returns The current instance for method chaining
|
|
176
|
+
*/
|
|
177
|
+
resize(cached?: {
|
|
178
|
+
size: number;
|
|
179
|
+
height?: number;
|
|
180
|
+
margin: {
|
|
181
|
+
prev: number;
|
|
182
|
+
next: number;
|
|
183
|
+
};
|
|
184
|
+
}): this;
|
|
185
|
+
/**
|
|
186
|
+
* Change panel's size
|
|
187
|
+
* @remarks
|
|
188
|
+
* This will change the actual size of the panel element by changing its CSS width/height property.
|
|
189
|
+
* @param size - {@link SetSizeParams}
|
|
190
|
+
* @returns The current instance for method chaining
|
|
191
|
+
*/
|
|
192
|
+
setSize(size: SetSizeParams): this;
|
|
193
|
+
/**
|
|
194
|
+
* Check whether the given element is inside of this panel's {@link Panel.element | element}
|
|
195
|
+
* @remarks
|
|
196
|
+
* This is useful for determining which panel contains a clicked element.
|
|
197
|
+
* @param element - The HTMLElement to check
|
|
198
|
+
* @returns A Boolean value indicating the element is inside of this panel {@link Panel.element | element}
|
|
199
|
+
*/
|
|
200
|
+
contains(element: HTMLElement): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Reset internal state and set {@link Panel.removed | removed} to `true`
|
|
203
|
+
* @remarks
|
|
204
|
+
* After calling this method, the panel should no longer be used.
|
|
205
|
+
*/
|
|
206
|
+
destroy(): void;
|
|
207
|
+
/**
|
|
208
|
+
* Check whether the given position is inside of this panel's {@link Panel.range | range}
|
|
209
|
+
* @param pos - A position to check
|
|
210
|
+
* @param includeMargin - Include {@link Panel.margin | margin} to the range
|
|
211
|
+
* @returns A Boolean value indicating whether the given position is included in the panel range
|
|
212
|
+
*/
|
|
213
|
+
includePosition(pos: number, includeMargin?: boolean): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Check whether the given range is fully included in this panel's area (inclusive)
|
|
216
|
+
* @param min - Minimum value of the range to check
|
|
217
|
+
* @param max - Maximum value of the range to check
|
|
218
|
+
* @param includeMargin - Include {@link Panel.margin | margin} to the range
|
|
219
|
+
* @returns A Boolean value indicating whether the given range is fully included in the panel range
|
|
220
|
+
*/
|
|
221
|
+
includeRange(min: number, max: number, includeMargin?: boolean): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Check whether the panel is visble in the given range (exclusive)
|
|
224
|
+
* @param min - Minimum value of the range to check
|
|
225
|
+
* @param max - Maximum value of the range to check
|
|
226
|
+
* @returns A Boolean value indicating whether the panel is visible
|
|
227
|
+
*/
|
|
228
|
+
isVisibleOnRange(min: number, max: number): boolean;
|
|
229
|
+
/**
|
|
230
|
+
* Move {@link Camera} to this panel
|
|
231
|
+
* @remarks
|
|
232
|
+
* This is equivalent to calling `Flicking.moveTo(panel.index, duration)`.
|
|
233
|
+
* @param duration - Duration of the animation (unit: ms). Defaults to {@link FlickingOptions.duration}
|
|
234
|
+
* @fires {@link MovementEvents}
|
|
235
|
+
* @throws {@link MovementErrors}
|
|
236
|
+
* @returns A Promise which will be resolved after reaching the panel
|
|
237
|
+
*/
|
|
238
|
+
focus(duration?: number): Promise<void>;
|
|
239
|
+
/**
|
|
240
|
+
* Get previous(`index - 1`) panel.
|
|
241
|
+
* @remarks
|
|
242
|
+
* When the previous panel does not exist, this will return `null` instead
|
|
243
|
+
* If the {@link Flicking.circularEnabled | circular} is enabled, this will return the last panel if called from the first panel
|
|
244
|
+
* @returns The previous panel
|
|
245
|
+
*/
|
|
246
|
+
prev(): Panel | null;
|
|
247
|
+
/**
|
|
248
|
+
* Get next(`index + 1`) panel.
|
|
249
|
+
* @remarks
|
|
250
|
+
* When the next panel does not exist, this will return `null` instead
|
|
251
|
+
* If the {@link Flicking.circularEnabled | circular} is enabled, this will return the first panel if called from the last panel
|
|
252
|
+
* @returns The next panel
|
|
253
|
+
*/
|
|
254
|
+
next(): Panel | null;
|
|
255
|
+
/**
|
|
256
|
+
* @internal
|
|
257
|
+
* @privateRemarks
|
|
258
|
+
* Increases the panel's index by the given value. Called when panels are inserted before this panel.
|
|
259
|
+
*/
|
|
260
|
+
increaseIndex(val: number): this;
|
|
261
|
+
/**
|
|
262
|
+
* @internal
|
|
263
|
+
* @privateRemarks
|
|
264
|
+
* Decreases the panel's index by the given value. Called when panels are removed before this panel.
|
|
265
|
+
*/
|
|
266
|
+
decreaseIndex(val: number): this;
|
|
267
|
+
/**
|
|
268
|
+
* @internal
|
|
269
|
+
* @privateRemarks
|
|
270
|
+
* Recalculates the panel's position based on the previous panel's position and margins.
|
|
271
|
+
*/
|
|
272
|
+
updatePosition(): this;
|
|
273
|
+
/**
|
|
274
|
+
* @internal
|
|
275
|
+
* @privateRemarks
|
|
276
|
+
* Toggles the panel's position for circular mode. Returns true if the panel was toggled.
|
|
277
|
+
*/
|
|
278
|
+
toggle(prevPos: number, newPos: number): boolean;
|
|
279
|
+
/**
|
|
280
|
+
* @internal
|
|
281
|
+
* @privateRemarks
|
|
282
|
+
* Updates the toggle direction for circular mode based on the panel's visibility at the camera range edges.
|
|
283
|
+
*/
|
|
284
|
+
updateCircularToggleDirection(): this;
|
|
285
|
+
/**
|
|
286
|
+
* @internal
|
|
287
|
+
* @privateRemarks
|
|
288
|
+
* Recalculates the align position based on the align option and panel size.
|
|
289
|
+
*/
|
|
290
|
+
private _updateAlignPos;
|
|
291
|
+
/**
|
|
292
|
+
* @internal
|
|
293
|
+
* @privateRemarks
|
|
294
|
+
* Resets all internal state values to their defaults.
|
|
295
|
+
*/
|
|
296
|
+
private _resetInternalStates;
|
|
297
|
+
}
|
|
298
|
+
export default Panel;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Panel, { PanelOptions } from "./Panel";
|
|
2
|
+
import VirtualElementProvider from "./provider/VirtualElementProvider";
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating a {@link VirtualPanel}
|
|
5
|
+
*/
|
|
6
|
+
export interface VirtualPanelOptions extends PanelOptions {
|
|
7
|
+
/** A provider instance that returns the actual html element */
|
|
8
|
+
elementProvider: VirtualElementProvider;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A slide data component that holds information of a single HTMLElement
|
|
12
|
+
*/
|
|
13
|
+
declare class VirtualPanel extends Panel {
|
|
14
|
+
protected _elProvider: VirtualElementProvider;
|
|
15
|
+
protected _cachedInnerHTML: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* `HTMLElement` that panel's referencing
|
|
18
|
+
* @readonly
|
|
19
|
+
*/
|
|
20
|
+
get element(): HTMLElement;
|
|
21
|
+
/**
|
|
22
|
+
* Cached innerHTML by the previous render function
|
|
23
|
+
* @readonly
|
|
24
|
+
*/
|
|
25
|
+
get cachedInnerHTML(): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* A number for indexing which element it will be rendered on
|
|
28
|
+
* @readonly
|
|
29
|
+
*/
|
|
30
|
+
get elementIndex(): number;
|
|
31
|
+
/**
|
|
32
|
+
* @param options - {@link VirtualPanelOptions}
|
|
33
|
+
*/
|
|
34
|
+
constructor(options: VirtualPanelOptions);
|
|
35
|
+
cacheRenderResult(result: string): void;
|
|
36
|
+
uncacheRenderResult(): void;
|
|
37
|
+
render(): void;
|
|
38
|
+
increaseIndex(val: number): this;
|
|
39
|
+
decreaseIndex(val: number): this;
|
|
40
|
+
}
|
|
41
|
+
export default VirtualPanel;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import Panel, { PanelBoundingBoxRange, PanelMarginInfo, PanelOptions } from "./Panel";
|
|
2
|
+
import VirtualPanel, { VirtualPanelOptions } from "./VirtualPanel";
|
|
3
|
+
export * from "./provider";
|
|
4
|
+
export { Panel, VirtualPanel };
|
|
5
|
+
export type { PanelOptions, PanelBoundingBoxRange, PanelMarginInfo, VirtualPanelOptions };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import Flicking from "../../../Flicking";
|
|
2
2
|
import VirtualPanel from "../VirtualPanel";
|
|
3
3
|
import ElementProvider from "./ElementProvider";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
4
7
|
declare class VirtualElementProvider implements ElementProvider {
|
|
5
8
|
private _flicking;
|
|
6
9
|
private _panel;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Special type of known error that {@link Flicking} throws.
|
|
3
|
+
* @remarks
|
|
4
|
+
* see {@link FlickingErrors} for possible error codes and explantaion
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import Flicking, { FlickingError, ERROR_CODES } from "@egjs/flicking";
|
|
8
|
+
* try {
|
|
9
|
+
* const flicking = new Flicking(".flicking-viewport")
|
|
10
|
+
* } catch (e) {
|
|
11
|
+
* if (e instanceof FlickingError && e.code === ERROR_CODES.ELEMENT_NOT_FOUND) {
|
|
12
|
+
* console.error(e.message)
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare class FlickingError extends Error {
|
|
18
|
+
code: number;
|
|
19
|
+
/**
|
|
20
|
+
* @param message - Error message
|
|
21
|
+
* @param code - Error code
|
|
22
|
+
*/
|
|
23
|
+
constructor(message: string, code: number);
|
|
24
|
+
}
|
|
25
|
+
export default FlickingError;
|