animare
Version:
Advanced animation library for modern JavaScript.
23 lines • 1.17 kB
TypeScript
import type { AutoPauseOptions, GroupTimelineObject, SingleObject, TimelineObject } from '../types.js';
/**
* Uses the IntersectionObserver API to automatically pauses the animation when the element is not visible.
*
* Plays the timeline when the element becomes visible, even if the timeline was not playing before.
*
* @param timeline - The animation object returned by animare.
* @param element - The HTML element to track when entering and exiting the viewport.
* @param options - The options for the intersection observer.
* @returns A function to remove the intersection observer and stop tracking visibility.
*
* @example
* const myTimeline = animare.timeline(...params);
*
* // The element to track when entering and exiting the viewport
* const element = document.getElementById('element');
*
* const unsubscribe = autoPause(myTimeline, element);
*
* unsubscribe(); // Disconnect the intersection observer
*/
export declare function autoPause<Name extends string>(timeline: TimelineObject<Name> | GroupTimelineObject | SingleObject, element: Element, observerOptions?: AutoPauseOptions): () => void;
//# sourceMappingURL=autoPause.d.ts.map