@anton.bobrov/react-vevet-hooks
Version:
A collection of custom React hooks designed to seamlessly integrate with the `Vevet` library
43 lines • 1.8 kB
TypeScript
import { NTimeline, Timeline } from 'vevet';
export interface IUseTimelineProps extends Pick<NTimeline.IStaticProps, 'easing'>, Pick<NTimeline.IChangeableProps, 'duration'> {
/** Callback event triggered when the timeline starts */
onStart?: () => void;
/** Callback event triggered on timeline progress update */
onProgress?: (data: NTimeline.ICallbacksTypes['progress']) => void;
/** Callback event triggered when the timeline ends */
onEnd?: () => void;
}
/**
* Custom React hook that creates a `vevet` timeline instance.
*
* This hook initializes a timeline with the specified properties and
* sets up event callbacks for timeline events such as start, progress,
* and end. It provides functions to control the playback of the timeline.
*
* @example
* const MyComponent = () => {
* const { play, pause, reset } = useTimeline({
* easing: EaseInBounce,
* duration: 1000,
* onStart: () => console.log('Timeline started'),
* onProgress: (data) => console.log('Progress:', data),
* onEnd: () => console.log('Timeline ended'),
* });
*
* return (
* <div>
* <button onClick={play}>Play</button>
* <button onClick={pause}>Pause</button>
* <button onClick={reset}>Reset</button>
* </div>
* );
* };
*/
export declare function useTimeline({ easing, onStart: onStartProp, onProgress: onProgressProp, onEnd: onEndProp, ...changeableProps }: IUseTimelineProps): {
timeline: Timeline<NTimeline.IStaticProps, NTimeline.IChangeableProps, NTimeline.ICallbacksTypes> | undefined;
play: () => void | undefined;
reverse: () => void | undefined;
pause: () => void | undefined;
reset: () => void | undefined;
};
//# sourceMappingURL=useTimeline.d.ts.map