@egjs/flicking
Version:
Everyday 30 million people experience. It's reliable, flexible and extendable carousel.
87 lines (86 loc) • 2.81 kB
TypeScript
import { OnAnimationEnd, OnChange, OnFinish, OnHold, OnRelease } from "@egjs/axes";
import Panel from "../../core/panel/Panel";
import Flicking from "../../Flicking";
export declare enum STATE_TYPE {
IDLE = 0,
HOLDING = 1,
DRAGGING = 2,
ANIMATING = 3,
DISABLED = 4
}
/**
* Event context for State event handlers
* @internal
*/
export interface StateContext<T> {
/** An instance of Flicking */
flicking: Flicking;
/** An Axes event */
axesEvent: T;
/** A function for changing current state to other state */
transitTo: (nextState: STATE_TYPE) => State;
}
/**
* A component that shows the current status of the user input or the animation
* @internal
*/
declare abstract class State {
/**
* Whether user is clicking or touching
* @readonly
*/
abstract readonly holding: boolean;
/**
* Whether Flicking's animating
* @readonly
*/
abstract readonly animating: boolean;
protected _delta: number;
protected _targetPanel: Panel | null;
/**
* A sum of delta values of change events from the last hold event of Axes
* @readonly
*/
get delta(): number;
/**
* A panel to set as {@link Control.activePanel} after the animation is finished
* @readonly
*/
get targetPanel(): Panel | null;
set targetPanel(val: Panel | null);
/**
* An callback which is called when state has changed to this state
* @param prevState - An previous state
*/
onEnter(prevState: State): void;
/**
* An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-hold | hold} event
* @param ctx - {@link StateContext}
*/
onHold(ctx: StateContext<OnHold>): void;
/**
* An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-change | change} event
* @param ctx - {@link StateContext}
*/
onChange(ctx: StateContext<OnChange>): void;
/**
* An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-release | release} event
* @param ctx - {@link StateContext}
*/
onRelease(ctx: StateContext<OnRelease>): void;
/**
* An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-animationEnd | animationEnd} event
* @param ctx - {@link StateContext}
*/
onAnimationEnd(ctx: StateContext<OnAnimationEnd>): void;
/**
* An event handler for Axes's {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-finish | finish} event
* @param ctx - {@link StateContext}
*/
onFinish(ctx: StateContext<OnFinish>): void;
/**
* @internal
*/
protected _moveToChangedPosition(ctx: StateContext<OnChange>): void;
}
export default State;