darkroomengineering / lenis

How smooth scroll should be
https://lenis.darkroom.engineering
MIT License
8.63k stars 372 forks source link

1.0.5: Scroll not working in some cases #156

Closed TomSmedley closed 1 year ago

TomSmedley commented 1 year ago

No error is returned by the browser so it's a tough one, I've created a loom however and downgraded in the meantime.

https://www.loom.com/share/d1e2da8edec94c59bda732e24867fc41

clementroche commented 1 year ago

No issues on codepen, can you share your implementation ? @TomSmedley

TomSmedley commented 1 year ago

Using Svelte I've done this in my +layout.svelte

onMount(() => {
    const lenis = new Lenis();

    function raf(time: number) {
        if (lenis) {
            lenis.raf(time);
            requestAnimationFrame(raf);
        }
    }
    requestAnimationFrame(raf);

    return () => lenis.destroy();
});

Downgrading to 1.0.4 fixes this issue

clementroche commented 1 year ago

Since it works on codepen, your implementation is wrong, maybe css or something ?

TomSmedley commented 1 year ago

Interesting, what would make wrong from 1.0.4 to 1.0.5?

clementroche commented 1 year ago

i don't know, can you share your website with 1.0.5 ?

TomSmedley commented 1 year ago

Code reproduction: https://stackblitz.com/edit/sveltejs-kit-template-default-sgdgiv?file=src/routes/+layout.svelte

Screen record: https://www.loom.com/share/45ac8bc31d794fa1b17951615be58883

Seems to be related to lenis.scrollTo(0, { immediate: true }) in some way. Though I'm not 100%.

clementroche commented 1 year ago

ok i can reproduce now, thank you

clementroche commented 1 year ago

fixed in v1.0.6