Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@studio-freight/react-lenis

Package Overview
Dependencies
Maintainers
5
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@studio-freight/react-lenis - npm Package Compare versions

Comparing version 0.0.43 to 0.0.44-dev.0

2

dist/react-lenis.cjs.js

@@ -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"),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};
"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(),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("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})}));
!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(),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

@@ -1,82 +0,22 @@

export function useLenis(callback?: CallbackFunction, deps?: any[] | undefined, priority?: number | undefined): LenisInstance;
export const LenisContext: any;
export default ReactLenis;
export type EasingFunction = (rawValue: number) => number;
export type CallbackFunction = (instance: LenisInstance) => any;
export type CallbackEvents = {
scroll: CallbackFunction[];
import Lenis, { LenisOptions } from '@studio-freight/lenis';
import React, { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
export declare const LenisContext: any;
export declare function useLenis(callback: Function, deps?: never[], priority?: number): any;
type ForwardRefComponent<P, T> = ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
type Props = {
root?: boolean;
options?: LenisOptions;
autoRaf?: boolean;
rafPriority?: number;
className?: string;
children?: React.ReactNode;
props?: any;
};
export type RAF = (time: number) => any;
export type ScrollToParams = {
offset?: number;
lerp?: number;
duration?: number;
easing?: EasingFunction;
immediate?: boolean;
lock?: boolean;
force?: boolean;
onComplete?: CallbackFunction;
type LenisRef = {
wrapper?: HTMLElement;
content?: HTMLElement;
lenis?: Lenis;
};
export type ScrollTo = (target: number | string | HTMLElement, options?: ScrollToParams) => any;
export type ReactLenisOptions = {
wrapper?: (HTMLElement | Window);
content?: HTMLElement | undefined;
wheelEventsTarget?: (HTMLElement | Window);
lerp?: number | undefined;
duration?: number | undefined;
easing?: EasingFunction | undefined;
orientation?: string | undefined;
gestureOrientation?: string | undefined;
smoothWheel?: boolean | undefined;
smoothTouch?: boolean | undefined;
syncTouch?: boolean | undefined;
syncTouchLerp?: number | undefined;
touchInertiaMultiplier?: number | undefined;
normalizeWheel?: boolean | undefined;
infinite?: boolean | undefined;
autoResize?: boolean | undefined;
};
export type Dimensions = {
wrapper: (HTMLElement | Window);
content: HTMLElement;
contentResizeObserver: ResizeObserver;
resize: () => void;
onContentResize: () => void;
onWrapperResize: () => void;
width: number;
height: number;
scrollWidth: number;
scrollHeight: number;
};
export type Emitter = {
events: CallbackEvents;
};
export type EventHandler = (id: string, fn: CallbackFunction) => any;
export type LenisInstance = {
animatedScroll: number;
dimensions: Dimensions;
direction: number;
emitter: Emitter;
options: ReactLenisOptions;
targetScroll: number;
time: number;
actualScroll: number;
velocity: number;
isHorizontal: boolean;
isScrolling: boolean;
isSmooth: boolean;
isStopped: boolean;
limit: number;
progress: number;
rootElement: HTMLElement;
scroll: number;
stop: () => void;
start: () => void;
resize: () => void;
destroy: () => void;
on: EventHandler;
scrollTo: ScrollTo;
raf: RAF;
};
export const ReactLenis: any;
export { ReactLenis as Lenis };
declare const ReactLenis: ForwardRefComponent<Props, LenisRef>;
export { ReactLenis as Lenis, ReactLenis };
export default ReactLenis;
{
"name": "@studio-freight/react-lenis",
"version": "0.0.43",
"version": "0.0.44-dev.0",
"repository": {

@@ -17,8 +17,8 @@ "type": "git",

"playground": "npm run dev --prefix ./playground",
"build": "npm-run-all --parallel build:dist build:types",
"build": "npm-run-all --parallel build:dist",
"build:dist": "rollup --bundleConfigAsCjs -c",
"build:types": "tsc --target esnext --allowJs -d --emitDeclarationOnly --declarationDir ./dist/types --removeComments ./src/index.jsx",
"watch:dist": "rollup --bundleConfigAsCjs -c -w",
"watch:types": "tsc --target esnext --allowJs -d --emitDeclarationOnly --declarationDir ./dist/types --removeComments --watch ./src/index.jsx",
"watch": "npm-run-all --parallel watch:dist watch:types",
"watch:types": "tsc --target esnext --allowJs -d --emitDeclarationOnly --declarationDir ./dist/types --removeComments --watch ./src/index.jsx --jsx react",
"watch": "npm-run-all --parallel watch:dist",
"git:commit": "git add -A && cross-var git commit -m \"$npm_package_name@$npm_package_version\"",

@@ -50,4 +50,4 @@ "git:tag": "cross-var git tag -a $npm_package_name@$npm_package_version -m \"$npm_package_name@$npm_package_version\"",

"dependencies": {
"@studio-freight/hamo": "^0.6.24",
"@studio-freight/lenis": "^1.0.33",
"@studio-freight/hamo": "^0.6.28",
"@studio-freight/lenis": "^1.0.35-dev.0",
"clsx": "^2.0.0",

@@ -54,0 +54,0 @@ "prop-types": "^15.8.1",

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc