Skip to content

Commit

Permalink
@studio-freight/[email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
clementroche committed Jan 4, 2024
1 parent 60a7d4d commit f210823
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 3,498 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"workspaces": [
"packages/*"
],
"scripts": {
"dev:lenis": "npm run dev --prefix ./packages/lenis",
"dev:react-lenis": "npm run dev --prefix ./packages/react-lenis"
},
"devDependencies": {
"@babel/core": "^7.23.6",
"@babel/preset-react": "^7.23.3",
Expand Down
12 changes: 6 additions & 6 deletions packages/lenis/dist/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ export default class Lenis {
lerp?: number;
infinite?: boolean;
orientation?: "vertical" | "horizontal";
gestureOrientation?: "both" | "vertical" | "horizontal";
gestureOrientation?: "vertical" | "horizontal" | "both";
touchMultiplier?: number;
wheelMultiplier?: number;
normalizeWheel?: boolean;
autoResize?: boolean;
});
options: {
wrapper: HTMLElement | Window;
wrapper: Window | HTMLElement;
content: HTMLElement;
wheelEventsTarget: HTMLElement | Window;
eventsTarget: HTMLElement | Window;
wheelEventsTarget: Window | HTMLElement;
eventsTarget: Window | HTMLElement;
smoothWheel: boolean;
smoothTouch: boolean;
syncTouch: boolean;
Expand All @@ -34,7 +34,7 @@ export default class Lenis {
easing: (t: number) => number;
lerp: number;
infinite: boolean;
gestureOrientation: "both" | "vertical" | "horizontal";
gestureOrientation: "vertical" | "horizontal" | "both";
orientation: "vertical" | "horizontal";
touchMultiplier: number;
wheelMultiplier: number;
Expand Down Expand Up @@ -86,7 +86,7 @@ export default class Lenis {
programmatic?: boolean;
}): void;
__preventNextScrollEvent: boolean;
get rootElement(): HTMLElement | Window;
get rootElement(): Window | HTMLElement;
get limit(): number;
get isHorizontal(): boolean;
get actualScroll(): any;
Expand Down
5 changes: 2 additions & 3 deletions packages/lenis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
"watch": "npm-run-all --parallel watch:dist watch:types",
"readme": "node update-readme.js",
"git:commit": "git add -A && cross-var git commit -m \"$npm_package_name@$npm_package_version\"",
"git:tag": "cross-var git tag -a v$npm_package_version -m \"$npm_package_name@$npm_package_version\"",
"git:tag": "cross-var git tag -a $npm_package_name@$npm_package_version -m \"$npm_package_name@$npm_package_version\"",
"git:push": "git push && git push --tags",
"postversion": "npm-run-all build readme git:commit git:tag git:push",
"test": "git add -A && cross-var echo $npm_package_name@$npm_package_version"
"postversion": "npm-run-all build readme git:commit git:tag git:push"
},
"sideEffects": false,
"source": "src/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-lenis/dist/react-lenis.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/react-lenis/dist/react-lenis.cjs.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/react-lenis/dist/react-lenis.mjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import{useFrame as r}from"@studio-freight/hamo";import e from"@studio-freight/lenis";import t from"prop-types";import o,{createContext as a,useEffect as n,forwardRef as c,useRef as s,useState as l,useCallback as i,useImperativeHandle as f,useContext as u}from"react";import{create as m}from"zustand";import p from"clsx";function d(){return d=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o])}return r},d.apply(this,arguments)}const b=a(),y=m((()=>({})));function h(r,e=[],t=0){const{lenis:o,addCallback:a,removeCallback:c}=function(){const r=u(b),e=y();return r??e}();return n((()=>{if(r&&a&&c&&o)return a(r,t),r(o),()=>{c(r)}}),[o,a,c,t,...e]),o}const v=c((({children:t,root:a=!1,options:c={},autoRaf:u=!0,rafPriority:m=0,className:h,...v},g)=>{const N=s(),k=s(),[C,O]=l(),j=s([]),P=i(((r,e)=>{j.current.push({callback:r,priority:e}),j.current.sort(((r,e)=>r.priority-e.priority))}),[]),w=i((r=>{j.current=j.current.filter((e=>e.callback!==r))}),[]);f(g,(()=>C),[C]),n((()=>{const r=new e({...c,...!a&&{wrapper:N.current,content:k.current}});return O(r),()=>{r.destroy(),O(void 0)}}),[a,JSON.stringify(c)]),r((r=>{u&&C?.raf(r)}),m),n((()=>{a&&C&&y.setState({lenis:C,addCallback:P,removeCallback:w})}),[a,C,P,w]);const E=i((r=>{for(let e=0;e<j.current.length;e++)j.current[e].callback(r)}),[]);n((()=>(C?.on("scroll",E),()=>{C?.off("scroll",E)})),[C,E]);const R=i((()=>{N.current&&(N.current.className=p(C?.className,h))}),[C,h]);return n((()=>(R(),C?.on("className change",R),()=>{C?.off("className change",R)})),[C,R]),o.createElement(b.Provider,{value:{lenis:C,addCallback:P,removeCallback:w}},a?t:o.createElement("div",d({ref:N,className:p(C?.className,h)},v),o.createElement("div",{ref:k},t)))}));v.displayName="ReactLenis",v.propTypes={children:t.node,root:t.bool,options:t.object,autoRaf:t.bool,rafPriority:t.number,className:t.string};export{v as Lenis,b as LenisContext,v as ReactLenis,v as default,h as useLenis};
import{useFrame as r}from"@studio-freight/hamo";import e from"@studio-freight/lenis";import t from"clsx";import o from"prop-types";import a,{createContext as n,useEffect as c,forwardRef as s,useRef as l,useState as i,useCallback as u,useImperativeHandle as f,useContext as m}from"react";import{create as p}from"zustand";function d(){return d=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o])}return r},d.apply(this,arguments)}const b=n(),y=p((()=>({})));function h(r,e=[],t=0){const{lenis:o,addCallback:a,removeCallback:n}=function(){const r=m(b),e=y();return r??e}();return c((()=>{if(r&&a&&n&&o)return a(r,t),r(o),()=>{n(r)}}),[o,a,n,t,...e]),o}const v=s((({children:o,root:n=!1,options:s={},autoRaf:m=!0,rafPriority:p=0,className:h,...v},g)=>{const N=l(),k=l(),[C,O]=i(),j=l([]),w=u(((r,e)=>{j.current.push({callback:r,priority:e}),j.current.sort(((r,e)=>r.priority-e.priority))}),[]),P=u((r=>{j.current=j.current.filter((e=>e.callback!==r))}),[]);f(g,(()=>({wrapper:N.current,content:k.current,lenis:C})),[C]),c((()=>{const r=new e({...s,...!n&&{wrapper:N.current,content:k.current}});return O(r),()=>{r.destroy(),O(void 0)}}),[n,JSON.stringify(s)]),r((r=>{m&&C?.raf(r)}),p),c((()=>{n&&C&&y.setState({lenis:C,addCallback:w,removeCallback:P})}),[n,C,w,P]);const E=u((r=>{for(let e=0;e<j.current.length;e++)j.current[e].callback(r)}),[]);c((()=>(C?.on("scroll",E),()=>{C?.off("scroll",E)})),[C,E]);const R=u((()=>{N.current&&(N.current.className=t(C?.className,h))}),[C,h]);return c((()=>(R(),C?.on("className change",R),()=>{C?.off("className change",R)})),[C,R]),a.createElement(b.Provider,{value:{lenis:C,addCallback:w,removeCallback:P}},n?o:a.createElement("div",d({ref:N,className:t(C?.className,h)},v),a.createElement("div",{ref:k},o)))}));v.displayName="ReactLenis",v.propTypes={children:o.node,root:o.bool,options:o.object,autoRaf:o.bool,rafPriority:o.number,className:o.string};export{v as Lenis,b as LenisContext,v as ReactLenis,v as default,h as useLenis};
//# sourceMappingURL=react-lenis.mjs.map
Loading

1 comment on commit f210823

@vercel
Copy link

@vercel vercel bot commented on f210823 Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.