animare
Version:
Advanced animation library for modern JavaScript.
21 lines • 976 B
JavaScript
;Object.defineProperty(exports,"__esModule",{value:true});exports.useScrollAnimation=useScrollAnimation;var _plugins=require("animare/plugins");var _hooks=require("preact/hooks");/**
*
* Makes the scroll progress control the timeline.
*
* @param options — The options for configuring the scroll-controlled animation.
* @returns — A function to remove the scroll event listener.
*
* @example
* const scrollAnim = useAnimare(() => {
* // ...
* });
*
* useScrollAnimation({
* timeline: scrollAnim,
* element: document.querySelector<HTMLDivElement>('.block')!,
* start: ScrollElementEdge.Bottom,
* end: ScrollElementEdge.Top,
* startOffset: 100,
* });
*/function useScrollAnimation(options){let deps=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];(0,_hooks.useEffect)(()=>{const unSub=(0,_plugins.scrollAnimation)(options);return unSub;// eslint-disable-next-line react-hooks/exhaustive-deps
},[options.timeline,...deps]);}