@studio-freight/react-lenis
Advanced tools
Comparing version 0.0.46-dev.1 to 0.0.46
@@ -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"),s=require("zustand");"function"==typeof SuppressedError&&SuppressedError;"undefined"!=typeof window&&(window.reactLenisVersion="0.0.46-dev.1");const a=n.createContext(),l=s.create((()=>({})));const c=n.forwardRef(((s,c)=>{var{children:o,root:u=!1,options:i={},autoRaf:f=!0,rafPriority:p=0,className:d}=s,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 s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)r.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(t[n[s]]=e[n[s]])}return t}(s,["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(a.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=a,exports.ReactLenis=c,exports.default=c,exports.useLenis=function(e,r=[],t=0){const{lenis:s,addCallback:c,removeCallback:o}=function(){const e=n.useContext(a),r=l();return null!=e?e:r}();return n.useEffect((()=>{if(e&&c&&o&&s)return c(e,t),e(s),()=>{o(e)}}),[s,c,o,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"),n=require("react"),s=require("zustand");"function"==typeof SuppressedError&&SuppressedError;"undefined"!=typeof window&&(window.reactLenisVersion="0.0.46");const a=n.createContext(),l=s.create((()=>({})));const c=n.forwardRef(((s,c)=>{var{children:o,root:u=!1,options:i={},autoRaf:f=!0,rafPriority:p=0,className:d}=s,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 s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)r.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(t[n[s]]=e[n[s]])}return t}(s,["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(a.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=a,exports.ReactLenis=c,exports.default=c,exports.useLenis=function(e,r=[],t=0){const{lenis:s,addCallback:c,removeCallback:o}=function(){const e=n.useContext(a),r=l();return null!=e?e:r}();return n.useEffect((()=>{if(e&&c&&o&&s)return c(e,t),e(s),()=>{o(e)}}),[s,c,o,t,...r]),s}; | ||
//# 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,s,a){"use strict";"function"==typeof SuppressedError&&SuppressedError;"undefined"!=typeof window&&(window.reactLenisVersion="0.0.46-dev.1");const o=s.createContext(),c=a.create((()=>({})));const l=s.forwardRef(((e,a)=>{var{children:l,root:i=!1,options:u={},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 s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]])}return r}(e,["children","root","options","autoRaf","rafPriority","className"]);const m=s.useRef(),y=s.useRef(),[h,v]=s.useState(),g=s.useRef([]),O=s.useCallback(((e,t)=>{g.current.push({callback:e,priority:t}),g.current.sort(((e,t)=>e.priority-t.priority))}),[]),k=s.useCallback((e=>{g.current=g.current.filter((t=>t.callback!==e))}),[]);s.useImperativeHandle(a,(()=>({wrapper:m.current,content:y.current,lenis:h})),[h]),s.useEffect((()=>{const e=new r(Object.assign(Object.assign({},u),!i&&{wrapper:m.current,content:y.current}));return v(e),()=>{e.destroy(),v(void 0)}}),[i,JSON.stringify(u)]),t.useFrame((e=>{f&&(null==h||h.raf(e))}),d),s.useEffect((()=>{i&&h&&c.setState({lenis:h,addCallback:O,removeCallback:k})}),[i,h,O,k]);const C=s.useCallback((e=>{for(let t=0;t<g.current.length;t++)g.current[t].callback(e)}),[]);s.useEffect((()=>(null==h||h.on("scroll",C),()=>{null==h||h.off("scroll",C)})),[h,C]);const w=s.useCallback((()=>{m.current&&(m.current.className=n(null==h?void 0:h.className,p))}),[h,p]);return s.useEffect((()=>(w(),null==h||h.on("className change",w),()=>{null==h||h.off("className change",w)})),[h,w]),s.createElement(o.Provider,{value:{lenis:h,addCallback:O,removeCallback:k}},i?l:s.createElement("div",Object.assign({ref:m,className:n(null==h?void 0:h.className,p)},b),s.createElement("div",{ref:y},l)))}));e.Lenis=l,e.LenisContext=o,e.ReactLenis=l,e.default=l,e.useLenis=function(e,t=[],r=0){const{lenis:n,addCallback:a,removeCallback:l}=function(){const e=s.useContext(o),t=c();return null!=e?e:t}();return s.useEffect((()=>{if(e&&a&&l&&n)return a(e,r),e(n),()=>{l(e)}}),[n,a,l,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,s,a){"use strict";"function"==typeof SuppressedError&&SuppressedError;"undefined"!=typeof window&&(window.reactLenisVersion="0.0.46");const o=s.createContext(),c=a.create((()=>({})));const l=s.forwardRef(((e,a)=>{var{children:l,root:i=!1,options:u={},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 s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]])}return r}(e,["children","root","options","autoRaf","rafPriority","className"]);const m=s.useRef(),y=s.useRef(),[h,g]=s.useState(),v=s.useRef([]),O=s.useCallback(((e,t)=>{v.current.push({callback:e,priority:t}),v.current.sort(((e,t)=>e.priority-t.priority))}),[]),k=s.useCallback((e=>{v.current=v.current.filter((t=>t.callback!==e))}),[]);s.useImperativeHandle(a,(()=>({wrapper:m.current,content:y.current,lenis:h})),[h]),s.useEffect((()=>{const e=new r(Object.assign(Object.assign({},u),!i&&{wrapper:m.current,content:y.current}));return g(e),()=>{e.destroy(),g(void 0)}}),[i,JSON.stringify(u)]),t.useFrame((e=>{f&&(null==h||h.raf(e))}),d),s.useEffect((()=>{i&&h&&c.setState({lenis:h,addCallback:O,removeCallback:k})}),[i,h,O,k]);const C=s.useCallback((e=>{for(let t=0;t<v.current.length;t++)v.current[t].callback(e)}),[]);s.useEffect((()=>(null==h||h.on("scroll",C),()=>{null==h||h.off("scroll",C)})),[h,C]);const w=s.useCallback((()=>{m.current&&(m.current.className=n(null==h?void 0:h.className,p))}),[h,p]);return s.useEffect((()=>(w(),null==h||h.on("className change",w),()=>{null==h||h.off("className change",w)})),[h,w]),s.createElement(o.Provider,{value:{lenis:h,addCallback:O,removeCallback:k}},i?l:s.createElement("div",Object.assign({ref:m,className:n(null==h?void 0:h.className,p)},b),s.createElement("div",{ref:y},l)))}));e.Lenis=l,e.LenisContext=o,e.ReactLenis=l,e.default=l,e.useLenis=function(e,t=[],r=0){const{lenis:n,addCallback:a,removeCallback:l}=function(){const e=s.useContext(o),t=c();return null!=e?e:t}();return s.useEffect((()=>{if(e&&a&&l&&n)return a(e,r),e(n),()=>{l(e)}}),[n,a,l,r,...t]),n},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=react-lenis.umd.js.map |
import Lenis, { LenisOptions } from '@studio-freight/lenis'; | ||
import { ForwardRefExoticComponent, PropsWithoutRef, ReactNode, RefAttributes } from 'react'; | ||
export declare const LenisContext: Lenis | null; | ||
export declare function useLenis(callback: (lenis: Lenis) => void, deps?: Array<any>, priority?: number): Lenis | undefined; | ||
export declare function useLenis(callback?: (lenis: Lenis) => void, deps?: Array<any>, priority?: number): Lenis | undefined; | ||
type ForwardRefComponent<P, T> = ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>; | ||
@@ -6,0 +6,0 @@ type Props = { |
{ | ||
"name": "@studio-freight/react-lenis", | ||
"version": "0.0.46-dev.1", | ||
"version": "0.0.46", | ||
"repository": { | ||
@@ -27,3 +27,3 @@ "type": "git", | ||
"postversion": "npm-run-all build git:commit git:tag git:push", | ||
"version:latest": "yarn version --no-git-tag-version", | ||
"version:latest": "yarn version --no-git-tag-version --patch", | ||
"version:dev": "yarn version --no-git-tag-version --prerelease --preid dev" | ||
@@ -53,3 +53,3 @@ }, | ||
"@studio-freight/hamo": "^0.6.28", | ||
"@studio-freight/lenis": "^1.0.39", | ||
"@studio-freight/lenis": "^1.0.40", | ||
"clsx": "^2.0.0", | ||
@@ -56,0 +56,0 @@ "zustand": "^4.4.7" |
@@ -0,0 +0,0 @@ ![NPM Version](https://img.shields.io/npm/v/%40studio-freight%2Freact-lenis?colorA=000000&colorB=ff98a2) |
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
93540