UNPKG

@infinityfx/lively

Version:

Feature complete, lightweight react animation library.

4 lines (3 loc) 580 B
"use client"; import{useLayoutEffect as t}from"react";import e from"./use-link.js";function r({restore:r=0,target:o}={}){const n=e({x:0,y:0,top:0,left:0});return t((()=>{const t=o?.current?o.current:window;function e(t){const e=o?.current||document.documentElement,r=e.scrollLeft,c=r/(e.scrollWidth-e.clientWidth||1),l=e.scrollTop,s=l/(e.scrollHeight-e.clientHeight||1);n.set({x:c,y:s,top:l,left:r},{duration:t})}e(r);const c=()=>e();return t.addEventListener("scroll",c),()=>t.removeEventListener("scroll",c)}),[o]),n}export{r as default}; //# sourceMappingURL=use-scroll.js.map