vevet
Version:
Vevet is a JavaScript library for creative development that simplifies crafting rich interactions like split text animations, carousels, marquees, preloading, and more.
66 lines • 2.46 kB
TypeScript
import { Module, TModuleOnCallbacksProps } from '../../base/Module';
import { TRequiredProps } from '../../internal/requiredProps';
import { IRafCallbacksMap, IRafMutableProps, IRafStaticProps } from './types';
export * from './types';
type TC = IRafCallbacksMap;
type TS = IRafStaticProps;
type TM = IRafMutableProps;
/**
* Manages an animation frame loop with configurable FPS and playback controls.
*
* [Documentation](https://vevetjs.com/docs/Raf)
*
* @group Components
*/
export declare class Raf extends Module<TC, TS, TM> {
/** Get default static properties */
_getStatic(): TRequiredProps<TS>;
/** Get default mutable properties */
_getMutable(): TRequiredProps<TM>;
/** Indicates if the animation frame is currently running */
private _isPlaying;
/** Active requestAnimationFrame ID, or `null` if not running */
private _raf;
/** Timestamp of the last frame */
private _lastTimestamp;
/** Timestamp of the current frame */
private _timestamp;
/** Current frame index */
private _index;
/** Real-time FPS */
private _fps;
/** Duration of the last frame in ms */
private _duration;
constructor(props?: TS & TM & TModuleOnCallbacksProps<TC, Raf>, onCallbacks?: TModuleOnCallbacksProps<TC, Raf>);
/** Playback state of the animation frame */
get isPlaying(): boolean;
/** Timestamp of the current frame */
get timestamp(): number;
/** Current frame index */
get index(): number;
/** Real-time FPS */
get fps(): number;
/** Duration of the last frame in ms */
get duration(): number;
/** Scaling coefficient based on a 60 FPS target */
get fpsFactor(): number;
/** Handle property mutations */
protected _handleProps(props: Partial<TM>): void;
/** Start the animation loop */
play(): void;
/** Internal method to start the loop */
private _play;
/** Pause the animation loop */
pause(): void;
/** Internal method to pause the loop */
private _pause;
/** Animation loop handler, calculates FPS, and triggers callbacks */
private _animate;
/** Calculate linear interpolation factor to make animations run the same regardless of FPS */
lerpFactor(ease: number): number;
/** Compute real-time FPS from frame durations */
private _computeFPS;
/** Destroy the animation frame and stop the loop */
protected _destroy(): void;
}
//# sourceMappingURL=index.d.ts.map