Before </body> tag
<script src="https://unpkg.com/lenis@1.3.1/dist/lenis.min.js"></script>
<script>
window.Webflow ||= [];
window.Webflow.push(() => {
// Run only on desktop
if (!window.matchMedia('(min-width: 768px)').matches) return;
// Event listener for website loading (IMPORTANT)
window.addEventListener('load', () => {
const lenis = new Lenis({
duration: 0.9,
easing: (t) => 1 - Math.pow(1 - t, 3),
smoothWheel: true,
smoothTouch: false,
});
function raf(time) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
// Sync Lenis with GSAP
lenis.on('scroll', ScrollTrigger.update);
ScrollTrigger.refresh();
});
});
</script>