Created
April 22, 2023 15:33
-
-
Save Jokanstudio/54286a481ea79b329942a7a93a27e176 to your computer and use it in GitHub Desktop.
Webflow-Smooth-Scroll-Lenis /javascript-code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="https://cdn.jsdelivr.net/gh/studio-freight/lenis@0.2.28/bundled/lenis.js"></script> | |
| <script> | |
| const lenis = new Lenis({ | |
| duration: 1.2, | |
| easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // https://www.desmos.com/calculator/brs54l4xou | |
| direction: 'vertical', // vertical, horizontal | |
| gestureDirection: 'vertical', // vertical, horizontal, both | |
| smooth: true, | |
| mouseMultiplier: 1, | |
| smoothTouch: false, | |
| touchMultiplier: 2, | |
| infinite: false, | |
| }) | |
| //get scroll value | |
| lenis.on('scroll', ({ scroll, limit, velocity, direction, progress }) => { console.log({ scroll, limit, velocity, direction, progress }) | |
| }) | |
| function raf(time) { | |
| lenis.raf(time) | |
| requestAnimationFrame(raf) | |
| } | |
| requestAnimationFrame(raf) | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why On scroll text and other elements blink