lenis 1.1.13 → 1.1.14-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -56,18 +56,22 @@ using scripts:
56
56
  ### Basic:
57
57
 
58
58
  ```js
59
- const lenis = new Lenis()
59
+ // Initialize Lenis
60
+ const lenis = new Lenis();
60
61
 
62
+ // Listen for the scroll event and log the event data
61
63
  lenis.on('scroll', (e) => {
62
- console.log(e)
63
- })
64
+ console.log(e);
65
+ });
64
66
 
67
+ // Use requestAnimationFrame to continuously update the scroll
65
68
  function raf(time) {
66
- lenis.raf(time)
67
- requestAnimationFrame(raf)
69
+ lenis.raf(time);
70
+ requestAnimationFrame(raf);
68
71
  }
69
72
 
70
- requestAnimationFrame(raf)
73
+ requestAnimationFrame(raf);
74
+
71
75
  ```
72
76
 
73
77
  #### Recommended CSS:
@@ -108,19 +112,26 @@ import 'lenis/dist/lenis.css'
108
112
 
109
113
  ### GSAP ScrollTrigger:
110
114
  ```js
111
- const lenis = new Lenis()
115
+ // Initialize a new Lenis instance for smooth scrolling
116
+ const lenis = new Lenis();
112
117
 
118
+ // Listen for the 'scroll' event and log the event data to the console
113
119
  lenis.on('scroll', (e) => {
114
- console.log(e)
115
- })
120
+ console.log(e);
121
+ });
116
122
 
117
- lenis.on('scroll', ScrollTrigger.update)
123
+ // Synchronize Lenis scrolling with GSAP's ScrollTrigger plugin
124
+ lenis.on('scroll', ScrollTrigger.update);
118
125
 
119
- gsap.ticker.add((time)=>{
120
- lenis.raf(time * 1000)
121
- })
126
+ // Add Lenis's requestAnimationFrame (raf) method to GSAP's ticker
127
+ // This ensures Lenis's smooth scroll animation updates on each GSAP tick
128
+ gsap.ticker.add((time) => {
129
+ lenis.raf(time * 1000); // Convert time from seconds to milliseconds
130
+ });
131
+
132
+ // Disable lag smoothing in GSAP to prevent any delay in scroll animations
133
+ gsap.ticker.lagSmoothing(0);
122
134
 
123
- gsap.ticker.lagSmoothing(0)
124
135
  ```
125
136
 
126
137
  ### React:
@@ -147,7 +158,7 @@ See documentation for [lenis/react](https://github.com/darkroomengineering/lenis
147
158
  | `gestureOrientation` | `string` | `vertical` | The orientation of the gestures. Can be `vertical`, `horizontal` or `both` |
148
159
  | `syncTouch` | `boolean` | `false` | Mimic touch device scroll while allowing scroll sync (can be unstable on iOS<16) |
149
160
  | `syncTouchLerp` | `number` | `0.075` | Lerp applied during `syncTouch` inertia |
150
- | `touchInertiaMultiplier` | `number` | `35` | Manage the the strength of `syncTouch` inertia |
161
+ | `touchInertiaMultiplier` | `number` | `35` | Manage the strength of syncTouch inertia |
151
162
  | `wheelMultiplier` | `number` | `1` | The multiplier to use for mouse wheel events |
152
163
  | `touchMultiplier` | `number` | `1` | The multiplier to use for touch events |
153
164
  | `infinite` | `boolean` | `false` | Enable infinite scrolling! `syncTouch: true` is required on touch devices. ([See example](https://codepen.io/ClementRoche/pen/OJqBLod)) |
@@ -317,6 +328,8 @@ This set of hooks is curated and maintained by the darkroom.engineering team:
317
328
  - Clément Roche ([@clementroche\_](https://twitter.com/clementroche_)) – [darkroom.engineering](https://darkroom.engineering)
318
329
  - Guido Fier ([@uido15](https://twitter.com/uido15)) – [darkroom.engineering](https://darkroom.engineering)
319
330
  - Leandro Soengas ([@lsoengas](https://twitter.com/lsoengas)) - [darkroom.engineering](https://darkroom.engineering)
331
+ - Fermin Fernandez ([@Fermin_FerBridd](https://twitter.com/Fermin_FerBridd)) - [darkroom.engineering](https://darkroom.engineering)
332
+ - Felix Mayr ([@feledori](https://twitter.com/feledori)) - [darkroom.engineering](https://darkroom.engineering)
320
333
  - Franco Arza ([@arzafran](https://twitter.com/arzafran)) - [darkroom.engineering](https://darkroom.engineering)
321
334
 
322
335
  <br/>
@@ -1,10 +1,10 @@
1
- /// <reference types="react" />
2
1
  import * as react from 'react';
3
2
  import { ReactNode, ComponentPropsWithoutRef } from 'react';
4
- import Lenis, { ScrollCallback, LenisOptions } from 'lenis';
3
+ import * as Lenis from 'lenis';
4
+ import Lenis__default, { ScrollCallback, LenisOptions } from 'lenis';
5
5
 
6
6
  type LenisContextValue = {
7
- lenis: Lenis;
7
+ lenis: Lenis__default;
8
8
  addCallback: (callback: ScrollCallback, priority: number) => void;
9
9
  removeCallback: (callback: ScrollCallback) => void;
10
10
  };
@@ -61,10 +61,14 @@ type LenisRef = {
61
61
  /**
62
62
  * The lenis instance
63
63
  */
64
- lenis?: Lenis;
64
+ lenis?: Lenis__default;
65
65
  };
66
66
 
67
- declare const LenisContext: react.Context<LenisContextValue | null>;
67
+ /**
68
+ * React component to setup a Lenis instance
69
+ */
70
+ declare const ReactLenis: react.ForwardRefExoticComponent<LenisProps & react.RefAttributes<LenisRef>>;
71
+
68
72
  /**
69
73
  * Hook to access the Lenis instance and its methods
70
74
  *
@@ -105,10 +109,6 @@ declare const LenisContext: react.Context<LenisContextValue | null>;
105
109
  * })
106
110
  * }
107
111
  */
108
- declare function useLenis(callback?: ScrollCallback, deps?: any[], priority?: number): Lenis | undefined;
109
- /**
110
- * React component to setup a Lenis instance
111
- */
112
- declare const ReactLenis: react.ForwardRefExoticComponent<LenisProps & react.RefAttributes<LenisRef>>;
112
+ declare function useLenis(callback?: ScrollCallback, deps?: any[], priority?: number): Lenis.default | undefined;
113
113
 
114
- export { ReactLenis as Lenis, LenisContext, type LenisContextValue, type LenisProps, type LenisRef, ReactLenis, ReactLenis as default, useLenis };
114
+ export { ReactLenis as Lenis, type LenisContextValue, type LenisProps, type LenisRef, ReactLenis, ReactLenis as default, useLenis };
@@ -0,0 +1,68 @@
1
+ import * as vue from 'vue';
2
+ import { PropType, HTMLAttributes, Plugin } from 'vue';
3
+ import * as lenis from 'lenis';
4
+ import { ScrollCallback } from 'lenis';
5
+
6
+ declare const VueLenis: vue.DefineComponent<{
7
+ root: {
8
+ type: PropType<boolean>;
9
+ default: boolean;
10
+ };
11
+ autoRaf: {
12
+ type: PropType<boolean>;
13
+ default: boolean;
14
+ };
15
+ rafPriority: {
16
+ type: PropType<number>;
17
+ default: number;
18
+ };
19
+ options: {
20
+ type: PropType<lenis.LenisOptions | undefined>;
21
+ default: () => {};
22
+ };
23
+ props: {
24
+ type: PropType<HTMLAttributes>;
25
+ default: () => {};
26
+ };
27
+ }, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
28
+ [key: string]: any;
29
+ }> | vue.VNode<vue.RendererNode, vue.RendererElement, {
30
+ [key: string]: any;
31
+ }>[] | undefined, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
32
+ root: {
33
+ type: PropType<boolean>;
34
+ default: boolean;
35
+ };
36
+ autoRaf: {
37
+ type: PropType<boolean>;
38
+ default: boolean;
39
+ };
40
+ rafPriority: {
41
+ type: PropType<number>;
42
+ default: number;
43
+ };
44
+ options: {
45
+ type: PropType<lenis.LenisOptions | undefined>;
46
+ default: () => {};
47
+ };
48
+ props: {
49
+ type: PropType<HTMLAttributes>;
50
+ default: () => {};
51
+ };
52
+ }>>, {
53
+ props: HTMLAttributes;
54
+ root: boolean;
55
+ autoRaf: boolean;
56
+ rafPriority: number;
57
+ options: lenis.LenisOptions | undefined;
58
+ }, {}>;
59
+ declare const vueLenisPlugin: Plugin;
60
+ declare module '@vue/runtime-core' {
61
+ interface GlobalComponents {
62
+ 'vue-lenis': typeof VueLenis;
63
+ }
64
+ }
65
+
66
+ declare function useLenis(callback?: ScrollCallback, priority?: number): vue.ComputedRef<lenis.default | undefined>;
67
+
68
+ export { VueLenis as Lenis, VueLenis, vueLenisPlugin as default, useLenis };