UNPKG

@infinityfx/lively

Version:

Feature complete, lightweight react animation library.

4 lines (3 loc) 612 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=(null==o?void 0:o.current)?o.current:window;function e(t){const e=(null==o?void 0:o.current)||document.documentElement,r=e.scrollLeft,l=r/(e.scrollWidth-e.clientWidth||1),c=e.scrollTop,i=c/(e.scrollHeight-e.clientHeight||1);n.set({x:l,y:i,top:c,left:r},{duration:t})}e(r);const l=()=>e();return t.addEventListener("scroll",l),()=>t.removeEventListener("scroll",l)}),[o]),n}export{r as default}; //# sourceMappingURL=use-scroll.js.map