@studio-freight/react-lenis
Advanced tools
Comparing version 0.0.44-dev.1 to 0.0.44-dev.2
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@studio-freight/hamo"),r=require("@studio-freight/lenis"),t=require("clsx"),n=require("react"),a=require("zustand");"function"==typeof SuppressedError&&SuppressedError;const s=n.createContext(null),l=a.create((()=>({})));const c=n.forwardRef(((a,c)=>{var{children:o,root:u=!1,options:i={},autoRaf:f=!0,rafPriority:p=0,className:d}=a,b=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(t[n[a]]=e[n[a]])}return t}(a,["children","root","options","autoRaf","rafPriority","className"]);const m=n.useRef(),y=n.useRef(),[v,O]=n.useState(),k=n.useRef([]),C=n.useCallback(((e,r)=>{k.current.push({callback:e,priority:r}),k.current.sort(((e,r)=>e.priority-r.priority))}),[]),g=n.useCallback((e=>{k.current=k.current.filter((r=>r.callback!==e))}),[]);n.useImperativeHandle(c,(()=>({wrapper:m.current,content:y.current,lenis:v})),[v]),n.useEffect((()=>{const e=new r(Object.assign(Object.assign({},i),!u&&{wrapper:m.current,content:y.current}));return O(e),()=>{e.destroy(),O(void 0)}}),[u,JSON.stringify(i)]),e.useFrame((e=>{f&&(null==v||v.raf(e))}),p),n.useEffect((()=>{u&&v&&l.setState({lenis:v,addCallback:C,removeCallback:g})}),[u,v,C,g]);const x=n.useCallback((e=>{for(let r=0;r<k.current.length;r++)k.current[r].callback(e)}),[]);n.useEffect((()=>(null==v||v.on("scroll",x),()=>{null==v||v.off("scroll",x)})),[v,x]);const h=n.useCallback((()=>{m.current&&(m.current.className=t(null==v?void 0:v.className,d))}),[v,d]);return n.useEffect((()=>(h(),null==v||v.on("className change",h),()=>{null==v||v.off("className change",h)})),[v,h]),React.createElement(s.Provider,{value:{lenis:v,addCallback:C,removeCallback:g}},u?o:React.createElement("div",Object.assign({ref:m,className:t(null==v?void 0:v.className,d)},b),React.createElement("div",{ref:y},o)))}));exports.Lenis=c,exports.LenisContext=s,exports.ReactLenis=c,exports.default=c,exports.useLenis=function(e,r=[],t=0){const{lenis:a,addCallback:c,removeCallback:o}=function(){const e=n.useContext(s),r=l();return null!=e?e:r}();return n.useEffect((()=>{if(e&&c&&o&&a)return c(e,t),e(a),()=>{o(e)}}),[a,c,o,t,...r]),a}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@studio-freight/hamo"),r=require("@studio-freight/lenis"),t=require("clsx"),n=require("react"),a=require("zustand");"function"==typeof SuppressedError&&SuppressedError;const s=n.createContext(null),l=a.create((()=>({})));const c=n.forwardRef(((a,c)=>{var{children:o,root:u=!1,options:i={},autoRaf:f=!0,rafPriority:p=0,className:d}=a,b=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(t[n[a]]=e[n[a]])}return t}(a,["children","root","options","autoRaf","rafPriority","className"]);const m=n.useRef(),y=n.useRef(),[v,O]=n.useState(),k=n.useRef([]),C=n.useCallback(((e,r)=>{k.current.push({callback:e,priority:r}),k.current.sort(((e,r)=>e.priority-r.priority))}),[]),g=n.useCallback((e=>{k.current=k.current.filter((r=>r.callback!==e))}),[]);n.useImperativeHandle(c,(()=>({wrapper:m.current,content:y.current,lenis:v})),[v]),n.useEffect((()=>{const e=new r(Object.assign(Object.assign({},i),!u&&{wrapper:m.current,content:y.current}));return O(e),()=>{e.destroy(),O(void 0)}}),[u,JSON.stringify(i)]),e.useFrame((e=>{f&&(null==v||v.raf(e))}),p),n.useEffect((()=>{u&&v&&l.setState({lenis:v,addCallback:C,removeCallback:g})}),[u,v,C,g]);const x=n.useCallback((e=>{for(let r=0;r<k.current.length;r++)k.current[r].callback(e)}),[]);n.useEffect((()=>(null==v||v.on("scroll",x),()=>{null==v||v.off("scroll",x)})),[v,x]);const h=n.useCallback((()=>{m.current&&(m.current.className=t(null==v?void 0:v.className,d))}),[v,d]);return n.useEffect((()=>(h(),null==v||v.on("className change",h),()=>{null==v||v.off("className change",h)})),[v,h]),n.createElement(s.Provider,{value:{lenis:v,addCallback:C,removeCallback:g}},u?o:n.createElement("div",Object.assign({ref:m,className:t(null==v?void 0:v.className,d)},b),n.createElement("div",{ref:y},o)))}));exports.Lenis=c,exports.LenisContext=s,exports.ReactLenis=c,exports.default=c,exports.useLenis=function(e,r=[],t=0){const{lenis:a,addCallback:c,removeCallback:o}=function(){const e=n.useContext(s),r=l();return null!=e?e:r}();return n.useEffect((()=>{if(e&&c&&o&&a)return c(e,t),e(a),()=>{o(e)}}),[a,c,o,t,...r]),a}; | ||
//# sourceMappingURL=react-lenis.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@studio-freight/hamo"),require("@studio-freight/lenis"),require("clsx"),require("react"),require("zustand")):"function"==typeof define&&define.amd?define(["exports","@studio-freight/hamo","@studio-freight/lenis","clsx","react","zustand"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactLenis={},e.hamo,e.Lenis,e.cn,e.React,e.zustand)}(this,(function(e,t,r,n,a,s){"use strict";"function"==typeof SuppressedError&&SuppressedError;const c=a.createContext(null),l=s.create((()=>({})));const o=a.forwardRef(((e,s)=>{var{children:o,root:u=!1,options:i={},autoRaf:f=!0,rafPriority:d=0,className:p}=e,b=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]])}return r}(e,["children","root","options","autoRaf","rafPriority","className"]);const m=a.useRef(),y=a.useRef(),[h,g]=a.useState(),v=a.useRef([]),O=a.useCallback(((e,t)=>{v.current.push({callback:e,priority:t}),v.current.sort(((e,t)=>e.priority-t.priority))}),[]),k=a.useCallback((e=>{v.current=v.current.filter((t=>t.callback!==e))}),[]);a.useImperativeHandle(s,(()=>({wrapper:m.current,content:y.current,lenis:h})),[h]),a.useEffect((()=>{const e=new r(Object.assign(Object.assign({},i),!u&&{wrapper:m.current,content:y.current}));return g(e),()=>{e.destroy(),g(void 0)}}),[u,JSON.stringify(i)]),t.useFrame((e=>{f&&(null==h||h.raf(e))}),d),a.useEffect((()=>{u&&h&&l.setState({lenis:h,addCallback:O,removeCallback:k})}),[u,h,O,k]);const C=a.useCallback((e=>{for(let t=0;t<v.current.length;t++)v.current[t].callback(e)}),[]);a.useEffect((()=>(null==h||h.on("scroll",C),()=>{null==h||h.off("scroll",C)})),[h,C]);const R=a.useCallback((()=>{m.current&&(m.current.className=n(null==h?void 0:h.className,p))}),[h,p]);return a.useEffect((()=>(R(),null==h||h.on("className change",R),()=>{null==h||h.off("className change",R)})),[h,R]),React.createElement(c.Provider,{value:{lenis:h,addCallback:O,removeCallback:k}},u?o:React.createElement("div",Object.assign({ref:m,className:n(null==h?void 0:h.className,p)},b),React.createElement("div",{ref:y},o)))}));e.Lenis=o,e.LenisContext=c,e.ReactLenis=o,e.default=o,e.useLenis=function(e,t=[],r=0){const{lenis:n,addCallback:s,removeCallback:o}=function(){const e=a.useContext(c),t=l();return null!=e?e:t}();return a.useEffect((()=>{if(e&&s&&o&&n)return s(e,r),e(n),()=>{o(e)}}),[n,s,o,r,...t]),n},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@studio-freight/hamo"),require("@studio-freight/lenis"),require("clsx"),require("react"),require("zustand")):"function"==typeof define&&define.amd?define(["exports","@studio-freight/hamo","@studio-freight/lenis","clsx","react","zustand"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactLenis={},e.hamo,e.Lenis,e.cn,e.React,e.zustand)}(this,(function(e,t,r,n,a,s){"use strict";"function"==typeof SuppressedError&&SuppressedError;const l=a.createContext(null),c=s.create((()=>({})));const o=a.forwardRef(((e,s)=>{var{children:o,root:u=!1,options:i={},autoRaf:f=!0,rafPriority:d=0,className:p}=e,b=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]])}return r}(e,["children","root","options","autoRaf","rafPriority","className"]);const m=a.useRef(),y=a.useRef(),[h,g]=a.useState(),v=a.useRef([]),O=a.useCallback(((e,t)=>{v.current.push({callback:e,priority:t}),v.current.sort(((e,t)=>e.priority-t.priority))}),[]),k=a.useCallback((e=>{v.current=v.current.filter((t=>t.callback!==e))}),[]);a.useImperativeHandle(s,(()=>({wrapper:m.current,content:y.current,lenis:h})),[h]),a.useEffect((()=>{const e=new r(Object.assign(Object.assign({},i),!u&&{wrapper:m.current,content:y.current}));return g(e),()=>{e.destroy(),g(void 0)}}),[u,JSON.stringify(i)]),t.useFrame((e=>{f&&(null==h||h.raf(e))}),d),a.useEffect((()=>{u&&h&&c.setState({lenis:h,addCallback:O,removeCallback:k})}),[u,h,O,k]);const C=a.useCallback((e=>{for(let t=0;t<v.current.length;t++)v.current[t].callback(e)}),[]);a.useEffect((()=>(null==h||h.on("scroll",C),()=>{null==h||h.off("scroll",C)})),[h,C]);const E=a.useCallback((()=>{m.current&&(m.current.className=n(null==h?void 0:h.className,p))}),[h,p]);return a.useEffect((()=>(E(),null==h||h.on("className change",E),()=>{null==h||h.off("className change",E)})),[h,E]),a.createElement(l.Provider,{value:{lenis:h,addCallback:O,removeCallback:k}},u?o:a.createElement("div",Object.assign({ref:m,className:n(null==h?void 0:h.className,p)},b),a.createElement("div",{ref:y},o)))}));e.Lenis=o,e.LenisContext=l,e.ReactLenis=o,e.default=o,e.useLenis=function(e,t=[],r=0){const{lenis:n,addCallback:s,removeCallback:o}=function(){const e=a.useContext(l),t=c();return null!=e?e:t}();return a.useEffect((()=>{if(e&&s&&o&&n)return s(e,r),e(n),()=>{o(e)}}),[n,s,o,r,...t]),n},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=react-lenis.umd.js.map |
{ | ||
"name": "@studio-freight/react-lenis", | ||
"version": "0.0.44-dev.1", | ||
"version": "0.0.44-dev.2", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
92586