@egjs/flicking
Version:
Everyday 30 million people experience. It's reliable, flexible and extendable carousel.
55 lines (54 loc) • 1.89 kB
TypeScript
import { OnRelease } from "@egjs/axes";
import Control from "./Control";
/**
* Options for the {@link SnapControl}
*/
export interface SnapControlOptions {
/** Maximum number of panels can go after release */
count: number;
}
/**
* A {@link Control} that uses a release momentum to choose destination panel
* @public
*/
declare class SnapControl extends Control {
private _count;
/**
* Maximum number of panels can go after release
* @defaultValue Infinity
*/
get count(): number;
set count(val: SnapControlOptions["count"]);
constructor(options?: Partial<SnapControlOptions>);
/**
* Move {@link Camera} to the given position
* @remarks
* This method calculates the snap target based on the release momentum and threshold settings.
* @param position - The target position to move
* @param duration - Duration of the panel movement animation (unit: ms)
* @param axesEvent - {@link https://naver.github.io/egjs-axes/docs/api/Axes#event-release | release} event of {@link https://naver.github.io/egjs-axes/ | Axes}
* @fires {@link MovementEvents}
* @throws {@link MovementErrors}
* @returns A Promise which will be resolved after reaching the target position
*/
moveToPosition(position: number, duration: number, axesEvent?: OnRelease): Promise<void>;
/**
* @internal
* @privateRemarks
* Finds the anchor point to snap to based on the target position and count option.
*/
private _findSnappedAnchor;
/**
* @internal
* @privateRemarks
* Finds the adjacent anchor point based on the movement direction.
*/
private _findAdjacentAnchor;
/**
* @internal
* @privateRemarks
* Calculates the snap threshold based on the panel size and alignment.
*/
private _calcSnapThreshold;
}
export default SnapControl;