animare
Version:
Advanced animation library for modern JavaScript.
75 lines • 2.27 kB
TypeScript
import { Event } from '../types.js';
import type { EventCallback, EventUnsubscribe } from '../types.js';
export default class EventManager {
#private;
/**
* Attaches an event listener to the timeline.
*
* @param event - The event to listen for.
* @param callback - The callback function to be executed when the event is triggered.
* @returns A function to unsubscribe the event listener.
*
* @example
* const unsubscribe = on(Event.Play, () => {
* // do something
* });
*
* unsubscribe(); // To remove the event listener
*/
on(event: Event, callback: EventCallback): EventUnsubscribe;
/**
* Attaches an event listener to the timeline that will be triggered only once.
*
* @param event - The event to listen for.
* @param callback - The callback function to be executed when the event is triggered.
* @returns A function to unsubscribe the event listener.
*
* @example
* const unsubscribe = once(Event.Play, () => {
* // do something
* });
*
* unsubscribe(); // To remove the event listener
*/
once(event: Event, callback: EventCallback): EventUnsubscribe;
emit(event: Event): void;
/** Removes all event listeners. */
clear(): void;
/**
* Waits until the timeline starts playing.
* @example
* await onPlayAsync();
*/
onPlayAsync(): Promise<unknown> | undefined;
/**
* Waits until the timeline resumes.
* @example
* await onResumeAsync();
*/
onResumeAsync(): Promise<unknown> | undefined;
/**
* Waits until the timeline pauses.
* @example
* await onPauseAsync();
*/
onPauseAsync(): Promise<unknown> | undefined;
/**
* Waits until the timeline stops.
* @example
* await onStopAsync();
*/
onStopAsync(): Promise<unknown> | undefined;
/**
* Waits until the timeline completes.
* @example
* await onCompleteAsync();
*/
onCompleteAsync(): Promise<unknown> | undefined;
/**
* Waits until the timeline repeats.
* @example
* await onRepeatAsync();
*/
onRepeatAsync(): Promise<unknown> | undefined;
}
//# sourceMappingURL=EventManager.d.ts.map