@studio-freight/react-lenis
Advanced tools
Comparing version 0.0.39 to 0.0.40
@@ -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("prop-types"),a=require("react"),s=require("zustand"),c=require("clsx");function n(){return n=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},n.apply(this,arguments)}const o=a.createContext(),l=s.create((()=>({})));const u=a.forwardRef((({children:t,root:s=!1,options:u={},autoRaf:i=!0,rafPriority:f=0,className:p,...d},b)=>{const m=a.useRef(),v=a.useRef(),[y,k]=a.useState(),C=a.useRef([]),h=a.useCallback(((e,r)=>{C.current.push({callback:e,priority:r}),C.current.sort(((e,r)=>e.priority-r.priority))}),[]),g=a.useCallback((e=>{C.current=C.current.filter((r=>r.callback!==e))}),[]);a.useImperativeHandle(b,(()=>y),[y]),a.useEffect((()=>{const e=new r({...u,...!s&&{wrapper:m.current,content:v.current}});return k(e),()=>{e.destroy(),k(void 0)}}),[s,JSON.stringify(u)]),e.useFrame((e=>{i&&y?.raf(e)}),f),a.useEffect((()=>{s&&y&&l.setState({lenis:y,addCallback:h,removeCallback:g})}),[s,y,h,g]);const x=a.useCallback((e=>{for(let r=0;r<C.current.length;r++)C.current[r].callback(e)}),[]);a.useEffect((()=>(y?.on("scroll",x),()=>{y?.off("scroll",x)})),[y,x]);const N=a.useCallback((()=>{m.current&&(m.current.className=c(y?.className,p))}),[y,p]);return a.useEffect((()=>(N(),y?.on("className change",N),()=>{y?.off("className change",N)})),[y,N]),a.createElement(o.Provider,{value:{lenis:y,addCallback:h,removeCallback:g}},s?t:a.createElement("div",n({ref:m,className:c(y?.className,p)},d),a.createElement("div",{ref:v},t)))}));u.displayName="ReactLenis",u.propTypes={children:t.node,root:t.bool,options:t.object,autoRaf:t.bool,rafPriority:t.number,className:t.string},exports.Lenis=u,exports.LenisContext=o,exports.ReactLenis=u,exports.default=u,exports.useLenis=function(e,r=[],t=0){const{lenis:s,addCallback:c,removeCallback:n}=function(){const e=a.useContext(o),r=l();return e??r}();return a.useEffect((()=>{if(e&&c&&n&&s)return c(e,t),e(s),()=>{n(e)}}),[s,c,n,t,...r]),s}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@studio-freight/hamo"),r=require("@studio-freight/lenis"),t=require("clsx"),a=require("prop-types"),s=require("react"),n=require("zustand");function c(){return c=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},c.apply(this,arguments)}const o=s.createContext(),l=n.create((()=>({})));const u=s.forwardRef((({children:a,root:n=!1,options:u={},autoRaf:i=!0,rafPriority:f=0,className:p,...d},b)=>{const m=s.useRef(),v=s.useRef(),[y,k]=s.useState(),C=s.useRef([]),h=s.useCallback(((e,r)=>{C.current.push({callback:e,priority:r}),C.current.sort(((e,r)=>e.priority-r.priority))}),[]),g=s.useCallback((e=>{C.current=C.current.filter((r=>r.callback!==e))}),[]);s.useImperativeHandle(b,(()=>({wrapper:m.current,content:v.current,lenis:y})),[y]),s.useEffect((()=>{const e=new r({...u,...!n&&{wrapper:m.current,content:v.current}});return k(e),()=>{e.destroy(),k(void 0)}}),[n,JSON.stringify(u)]),e.useFrame((e=>{i&&y?.raf(e)}),f),s.useEffect((()=>{n&&y&&l.setState({lenis:y,addCallback:h,removeCallback:g})}),[n,y,h,g]);const x=s.useCallback((e=>{for(let r=0;r<C.current.length;r++)C.current[r].callback(e)}),[]);s.useEffect((()=>(y?.on("scroll",x),()=>{y?.off("scroll",x)})),[y,x]);const N=s.useCallback((()=>{m.current&&(m.current.className=t(y?.className,p))}),[y,p]);return s.useEffect((()=>(N(),y?.on("className change",N),()=>{y?.off("className change",N)})),[y,N]),s.createElement(o.Provider,{value:{lenis:y,addCallback:h,removeCallback:g}},n?a:s.createElement("div",c({ref:m,className:t(y?.className,p)},d),s.createElement("div",{ref:v},a)))}));u.displayName="ReactLenis",u.propTypes={children:a.node,root:a.bool,options:a.object,autoRaf:a.bool,rafPriority:a.number,className:a.string},exports.Lenis=u,exports.LenisContext=o,exports.ReactLenis=u,exports.default=u,exports.useLenis=function(e,r=[],t=0){const{lenis:a,addCallback:n,removeCallback:c}=function(){const e=s.useContext(o),r=l();return e??r}();return s.useEffect((()=>{if(e&&n&&c&&a)return n(e,t),e(a),()=>{c(e)}}),[a,n,c,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("prop-types"),require("react"),require("zustand"),require("clsx")):"function"==typeof define&&define.amd?define(["exports","@studio-freight/hamo","@studio-freight/lenis","prop-types","react","zustand","clsx"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactLenis={},e.hamo,e.Lenis,e.PropTypes,e.React,e.zustand,e.cn)}(this,(function(e,t,r,a,s,n,o){"use strict";function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},c.apply(this,arguments)}const i=s.createContext(),l=n.create((()=>({})));const u=s.forwardRef((({children:e,root:a=!1,options:n={},autoRaf:u=!0,rafPriority:f=0,className:d,...p},b)=>{const m=s.useRef(),y=s.useRef(),[h,g]=s.useState(),k=s.useRef([]),v=s.useCallback(((e,t)=>{k.current.push({callback:e,priority:t}),k.current.sort(((e,t)=>e.priority-t.priority))}),[]),C=s.useCallback((e=>{k.current=k.current.filter((t=>t.callback!==e))}),[]);s.useImperativeHandle(b,(()=>h),[h]),s.useEffect((()=>{const e=new r({...n,...!a&&{wrapper:m.current,content:y.current}});return g(e),()=>{e.destroy(),g(void 0)}}),[a,JSON.stringify(n)]),t.useFrame((e=>{u&&h?.raf(e)}),f),s.useEffect((()=>{a&&h&&l.setState({lenis:h,addCallback:v,removeCallback:C})}),[a,h,v,C]);const N=s.useCallback((e=>{for(let t=0;t<k.current.length;t++)k.current[t].callback(e)}),[]);s.useEffect((()=>(h?.on("scroll",N),()=>{h?.off("scroll",N)})),[h,N]);const R=s.useCallback((()=>{m.current&&(m.current.className=o(h?.className,d))}),[h,d]);return s.useEffect((()=>(R(),h?.on("className change",R),()=>{h?.off("className change",R)})),[h,R]),s.createElement(i.Provider,{value:{lenis:h,addCallback:v,removeCallback:C}},a?e:s.createElement("div",c({ref:m,className:o(h?.className,d)},p),s.createElement("div",{ref:y},e)))}));u.displayName="ReactLenis",u.propTypes={children:a.node,root:a.bool,options:a.object,autoRaf:a.bool,rafPriority:a.number,className:a.string},e.Lenis=u,e.LenisContext=i,e.ReactLenis=u,e.default=u,e.useLenis=function(e,t=[],r=0){const{lenis:a,addCallback:n,removeCallback:o}=function(){const e=s.useContext(i),t=l();return e??t}();return s.useEffect((()=>{if(e&&n&&o&&a)return n(e,r),e(a),()=>{o(e)}}),[a,n,o,r,...t]),a},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("prop-types"),require("react"),require("zustand")):"function"==typeof define&&define.amd?define(["exports","@studio-freight/hamo","@studio-freight/lenis","clsx","prop-types","react","zustand"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactLenis={},e.hamo,e.Lenis,e.cn,e.PropTypes,e.React,e.zustand)}(this,(function(e,t,r,n,a,s,c){"use strict";function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},o.apply(this,arguments)}const i=s.createContext(),l=c.create((()=>({})));const u=s.forwardRef((({children:e,root:a=!1,options:c={},autoRaf:u=!0,rafPriority:f=0,className:d,...p},b)=>{const m=s.useRef(),y=s.useRef(),[h,g]=s.useState(),k=s.useRef([]),v=s.useCallback(((e,t)=>{k.current.push({callback:e,priority:t}),k.current.sort(((e,t)=>e.priority-t.priority))}),[]),C=s.useCallback((e=>{k.current=k.current.filter((t=>t.callback!==e))}),[]);s.useImperativeHandle(b,(()=>({wrapper:m.current,content:y.current,lenis:h})),[h]),s.useEffect((()=>{const e=new r({...c,...!a&&{wrapper:m.current,content:y.current}});return g(e),()=>{e.destroy(),g(void 0)}}),[a,JSON.stringify(c)]),t.useFrame((e=>{u&&h?.raf(e)}),f),s.useEffect((()=>{a&&h&&l.setState({lenis:h,addCallback:v,removeCallback:C})}),[a,h,v,C]);const N=s.useCallback((e=>{for(let t=0;t<k.current.length;t++)k.current[t].callback(e)}),[]);s.useEffect((()=>(h?.on("scroll",N),()=>{h?.off("scroll",N)})),[h,N]);const R=s.useCallback((()=>{m.current&&(m.current.className=n(h?.className,d))}),[h,d]);return s.useEffect((()=>(R(),h?.on("className change",R),()=>{h?.off("className change",R)})),[h,R]),s.createElement(i.Provider,{value:{lenis:h,addCallback:v,removeCallback:C}},a?e:s.createElement("div",o({ref:m,className:n(h?.className,d)},p),s.createElement("div",{ref:y},e)))}));u.displayName="ReactLenis",u.propTypes={children:a.node,root:a.bool,options:a.object,autoRaf:a.bool,rafPriority:a.number,className:a.string},e.Lenis=u,e.LenisContext=i,e.ReactLenis=u,e.default=u,e.useLenis=function(e,t=[],r=0){const{lenis:n,addCallback:a,removeCallback:c}=function(){const e=s.useContext(i),t=l();return e??t}();return s.useEffect((()=>{if(e&&a&&c&&n)return a(e,r),e(n),()=>{c(e)}}),[n,a,c,r,...t]),n},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=react-lenis.umd.js.map |
{ | ||
"name": "@studio-freight/react-lenis", | ||
"version": "0.0.39", | ||
"version": "0.0.40", | ||
"repository": { | ||
@@ -50,3 +50,3 @@ "type": "git", | ||
"@studio-freight/hamo": "^0.6.24", | ||
"@studio-freight/lenis": "^1.0.29", | ||
"@studio-freight/lenis": "^1.0.33", | ||
"clsx": "^2.0.0", | ||
@@ -53,0 +53,0 @@ "prop-types": "^15.8.1", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
53972
0