Do you know why scroll-behavior: smooth doesn't work with Lenis library of smooth -scrolling? When I comment the Lenis code below it works fine. When I add the Lenis code it doesn't scroll smoothly when I click the tag with id.
const lenis = new Lenis({
duration: 2.5
})
function raf(time) {
lenis.raf(time)
requestAnimationFrame(raf)
}
requestAnimationFrame(raf)
lenis.on('scroll', ScrollTrigger.update)
gsap.ticker.add((time) => {
lenis.raf(time * 1000)
})
html {
scroll-behavior: smooth;
}
<h2><a class="c-btn" href="#pages-main">scroll down</a></h2>
<section id="pages-main"></section>
Do you know why scroll-behavior: smooth doesn't work with Lenis library of smooth -scrolling? When I comment the Lenis code below it works fine. When I add the Lenis code it doesn't scroll smoothly when I click the tag with id.
const lenis = new Lenis({
duration: 2.5
})
function raf(time) {
lenis.raf(time)
requestAnimationFrame(raf)
}
requestAnimationFrame(raf)
lenis.on('scroll', ScrollTrigger.update)
gsap.ticker.add((time) => {
lenis.raf(time * 1000)
})
html {
scroll-behavior: smooth;
}
<h2><a class="c-btn" href="#pages-main">scroll down</a></h2>
<section id="pages-main"></section>
I have used react-lenis for this but it should probably work with the normal lenis package as well.