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
4
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.25 to 0.0.26

2

dist/react-lenis.js

@@ -1,2 +0,2 @@

var e=require("@studio-freight/hamo"),r=require("@studio-freight/lenis"),t=require("prop-types"),n=require("react"),a=require("zustand");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=/*#__PURE__*/u(r),i=/*#__PURE__*/u(t),c=/*#__PURE__*/u(n);function l(){return l=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},l.apply(this,arguments)}var f=n.createContext(),s=a.create(function(){return{}}),d=n.forwardRef(function(r,t){var a=r.children,u=r.root,i=void 0!==u&&u,d=r.options,v=void 0===d?{}:d,p=r.autoRaf,b=void 0===p||p,m=r.rafPriority,y=void 0===m?0:m,k=r.className,C=n.useRef(),h=n.useRef(),g=n.useState(),R=g[0],E=g[1],j=n.useRef([]),q=n.useCallback(function(e,r){j.current.push({callback:e,priority:r}),j.current.sort(function(e,r){return e.priority-r.priority})},[]),x=n.useCallback(function(e){j.current=j.current.filter(function(r){return r.callback!==e})},[]);n.useImperativeHandle(t,function(){return R},[R]),n.useEffect(function(){var e=new o.default(l({},v,!i&&{wrapper:C.current,content:h.current}));return E(e),function(){e.destroy(),E(void 0)}},[i,JSON.stringify(v)]),e.useFrame(function(e){b&&(null==R||R.raf(e))},y),n.useEffect(function(){i&&R&&s.setState({lenis:R,addCallback:q,removeCallback:x})},[i,R,q,x]);var N=n.useCallback(function(e){for(var r=0;r<j.current.length;r++)j.current[r].callback(e)},[]);return n.useEffect(function(){if(R)return R.on("scroll",N),function(){R.off("scroll",N)}},[R,N]),/*#__PURE__*/c.default.createElement(f.Provider,{value:{lenis:R,addCallback:q,removeCallback:x}},i?a:/*#__PURE__*/c.default.createElement("div",{ref:C,className:k},/*#__PURE__*/c.default.createElement("div",{ref:h},a)))});d.displayName="ReactLenis",d.propTypes={children:i.default.node,root:i.default.bool,options:i.default.object,autoRaf:i.default.bool,rafPriority:i.default.number,className:i.default.string},exports.Lenis=d,exports.ReactLenis=d,exports.useLenis=function(e,r,t){void 0===r&&(r=[]),void 0===t&&(t=0);var a,u,o=(a=n.useContext(f),u=s(),null!=a?a:u),i=o.lenis,c=o.addCallback,l=o.removeCallback;return n.useEffect(function(){if(e&&c&&l&&i)return c(e,t),e(i),function(){l(e)}},[i,c,l,t].concat(r)),i};
var e=require("@studio-freight/hamo"),r=require("@studio-freight/lenis"),t=require("prop-types"),n=require("react"),o=require("zustand");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=/*#__PURE__*/a(r),i=/*#__PURE__*/a(t),c=/*#__PURE__*/a(n);function f(){return f=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},f.apply(this,arguments)}var l=["children","root","options","autoRaf","rafPriority"],s=n.createContext(),d=o.create(function(){return{}}),v=n.forwardRef(function(r,t){var o=r.children,a=r.root,i=void 0!==a&&a,v=r.options,p=void 0===v?{}:v,b=r.autoRaf,y=void 0===b||b,k=r.rafPriority,h=void 0===k?0:k,m=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r.indexOf(t=a[n])>=0||(o[t]=e[t]);return o}(r,l),C=n.useRef(),R=n.useRef(),g=n.useState(),E=g[0],O=g[1],j=n.useRef([]),x=n.useCallback(function(e,r){j.current.push({callback:e,priority:r}),j.current.sort(function(e,r){return e.priority-r.priority})},[]),q=n.useCallback(function(e){j.current=j.current.filter(function(r){return r.callback!==e})},[]);n.useImperativeHandle(t,function(){return E},[E]),n.useEffect(function(){var e=new u.default(f({},p,!i&&{wrapper:C.current,content:R.current}));return O(e),function(){e.destroy(),O(void 0)}},[i,JSON.stringify(p)]),e.useFrame(function(e){y&&(null==E||E.raf(e))},h),n.useEffect(function(){i&&E&&d.setState({lenis:E,addCallback:x,removeCallback:q})},[i,E,x,q]);var P=n.useCallback(function(e){for(var r=0;r<j.current.length;r++)j.current[r].callback(e)},[]);return n.useEffect(function(){if(E)return E.on("scroll",P),function(){E.off("scroll",P)}},[E,P]),/*#__PURE__*/c.default.createElement(s.Provider,{value:{lenis:E,addCallback:x,removeCallback:q}},i?o:/*#__PURE__*/c.default.createElement("div",f({ref:C},m),/*#__PURE__*/c.default.createElement("div",{ref:R},o)))});v.displayName="ReactLenis",v.propTypes={children:i.default.node,root:i.default.bool,options:i.default.object,autoRaf:i.default.bool,rafPriority:i.default.number},exports.Lenis=v,exports.ReactLenis=v,exports.useLenis=function(e,r,t){void 0===r&&(r=[]),void 0===t&&(t=0);var o,a,u=(o=n.useContext(s),a=d(),null!=o?o:a),i=u.lenis,c=u.addCallback,f=u.removeCallback;return n.useEffect(function(){if(e&&c&&f&&i)return c(e,t),e(i),function(){f(e)}},[i,c,f,t].concat(r)),i};
//# sourceMappingURL=react-lenis.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")):"function"==typeof define&&define.amd?define(["exports","@studio-freight/hamo","@studio-freight/lenis","prop-types","react","zustand"],t):t((e||self).reactLenis={},e.hamo,e.Lenis,e.propTypes,e.react,e.zustand)}(this,function(e,t,r,n,a,o){function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=/*#__PURE__*/i(r),f=/*#__PURE__*/i(n),c=/*#__PURE__*/i(a);function l(){return l=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},l.apply(this,arguments)}var s=a.createContext(),d=o.create(function(){return{}}),p=a.forwardRef(function(e,r){var n=e.children,o=e.root,i=void 0!==o&&o,f=e.options,p=void 0===f?{}:f,v=e.autoRaf,b=void 0===v||v,y=e.rafPriority,m=void 0===y?0:y,h=e.className,g=a.useRef(),k=a.useRef(),C=a.useState(),R=C[0],E=C[1],j=a.useRef([]),L=a.useCallback(function(e,t){j.current.push({callback:e,priority:t}),j.current.sort(function(e,t){return e.priority-t.priority})},[]),q=a.useCallback(function(e){j.current=j.current.filter(function(t){return t.callback!==e})},[]);a.useImperativeHandle(r,function(){return R},[R]),a.useEffect(function(){var e=new u.default(l({},p,!i&&{wrapper:g.current,content:k.current}));return E(e),function(){e.destroy(),E(void 0)}},[i,JSON.stringify(p)]),t.useFrame(function(e){b&&(null==R||R.raf(e))},m),a.useEffect(function(){i&&R&&d.setState({lenis:R,addCallback:L,removeCallback:q})},[i,R,L,q]);var x=a.useCallback(function(e){for(var t=0;t<j.current.length;t++)j.current[t].callback(e)},[]);return a.useEffect(function(){if(R)return R.on("scroll",x),function(){R.off("scroll",x)}},[R,x]),/*#__PURE__*/c.default.createElement(s.Provider,{value:{lenis:R,addCallback:L,removeCallback:q}},i?n:/*#__PURE__*/c.default.createElement("div",{ref:g,className:h},/*#__PURE__*/c.default.createElement("div",{ref:k},n)))});p.displayName="ReactLenis",p.propTypes={children:f.default.node,root:f.default.bool,options:f.default.object,autoRaf:f.default.bool,rafPriority:f.default.number,className:f.default.string},e.Lenis=p,e.ReactLenis=p,e.useLenis=function(e,t,r){void 0===t&&(t=[]),void 0===r&&(r=0);var n,o,i=(n=a.useContext(s),o=d(),null!=n?n:o),u=i.lenis,f=i.addCallback,c=i.removeCallback;return a.useEffect(function(){if(e&&f&&c&&u)return f(e,r),e(u),function(){c(e)}},[u,f,c,r].concat(t)),u}});
!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")):"function"==typeof define&&define.amd?define(["exports","@studio-freight/hamo","@studio-freight/lenis","prop-types","react","zustand"],t):t((e||self).reactLenis={},e.hamo,e.Lenis,e.propTypes,e.react,e.zustand)}(this,function(e,t,r,n,o,i){function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=/*#__PURE__*/u(r),f=/*#__PURE__*/u(n),c=/*#__PURE__*/u(o);function l(){return l=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},l.apply(this,arguments)}var s=["children","root","options","autoRaf","rafPriority"],d=o.createContext(),p=i.create(function(){return{}}),v=o.forwardRef(function(e,r){var n=e.children,i=e.root,u=void 0!==i&&i,f=e.options,v=void 0===f?{}:f,b=e.autoRaf,y=void 0===b||b,h=e.rafPriority,m=void 0===h?0:h,k=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(o[r]=e[r]);return o}(e,s),g=o.useRef(),C=o.useRef(),R=o.useState(),j=R[0],E=R[1],O=o.useRef([]),x=o.useCallback(function(e,t){O.current.push({callback:e,priority:t}),O.current.sort(function(e,t){return e.priority-t.priority})},[]),L=o.useCallback(function(e){O.current=O.current.filter(function(t){return t.callback!==e})},[]);o.useImperativeHandle(r,function(){return j},[j]),o.useEffect(function(){var e=new a.default(l({},v,!u&&{wrapper:g.current,content:C.current}));return E(e),function(){e.destroy(),E(void 0)}},[u,JSON.stringify(v)]),t.useFrame(function(e){y&&(null==j||j.raf(e))},m),o.useEffect(function(){u&&j&&p.setState({lenis:j,addCallback:x,removeCallback:L})},[u,j,x,L]);var q=o.useCallback(function(e){for(var t=0;t<O.current.length;t++)O.current[t].callback(e)},[]);return o.useEffect(function(){if(j)return j.on("scroll",q),function(){j.off("scroll",q)}},[j,q]),/*#__PURE__*/c.default.createElement(d.Provider,{value:{lenis:j,addCallback:x,removeCallback:L}},u?n:/*#__PURE__*/c.default.createElement("div",l({ref:g},k),/*#__PURE__*/c.default.createElement("div",{ref:C},n)))});v.displayName="ReactLenis",v.propTypes={children:f.default.node,root:f.default.bool,options:f.default.object,autoRaf:f.default.bool,rafPriority:f.default.number},e.Lenis=v,e.ReactLenis=v,e.useLenis=function(e,t,r){void 0===t&&(t=[]),void 0===r&&(r=0);var n,i,u=(n=o.useContext(d),i=p(),null!=n?n:i),a=u.lenis,f=u.addCallback,c=u.removeCallback;return o.useEffect(function(){if(e&&f&&c&&a)return f(e,r),e(a),function(){c(e)}},[a,f,c,r].concat(t)),a}});
//# sourceMappingURL=react-lenis.umd.js.map

@@ -1,3 +0,16 @@

export function useLenis(callback: any, deps?: any[], priority?: number): any;
/**
* @param {function=} [callback] Callback to be called on scroll
* @param {Array=} [deps=[]] Dependencies for callback
* @param {number=} [priority=0] Priority of callback (lower priority callbacks are called first)
*
* @returns Lenis instance
*/
export function useLenis(callback?: Function | undefined, deps?: any[] | undefined, priority?: number | undefined): any;
/**
* @param {boolean=} [root] Whether Lenis will be initialized on document.documentElement
* @param {Object=} [options={}] Lenis options
* @param {boolean=} [autoRaf=true] Whether to call Lenis.raf automatically on every frame
* @param {number=} [rafPriority=0] Priority of Lenis.raf call (lower priority callbacks are called first)
*/
export const ReactLenis: any;
export { ReactLenis as Lenis };
{
"name": "@studio-freight/react-lenis",
"version": "0.0.25",
"version": "0.0.26",
"description": "a react wrapper for lenis smooth scroll library",

@@ -5,0 +5,0 @@ "files": [

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

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