locomotivemtl / locomotive-scroll

๐Ÿ›ค Detection of elements in viewport & smooth scrolling with parallax.
https://locomotivemtl.github.io/locomotive-scroll
MIT License
7.97k stars 1.12k forks source link

locomotive scroll == no dialog windows? #519

Open piscopancer opened 1 year ago

piscopancer commented 1 year ago

When I attempt to change an element to be scrolled by the locomotive it just does not work. I could see a workaround on the v5 docs using event listeners for a wheel, but it's such a mess I could not imagine writing this in my own app.

I also tried below code in Lenis before, same thing. There is absolutely no reaction from these libraries whatsoever ๐Ÿ˜•.

export function LocomotiveScroll() {
    const { locomotive, locomotiveContainer } = useGlobalSnapshot()

    useEffect(() => {
        store.locomotive = ref(new Locomotive())
    }, [])

    useEffect(() => {
        locomotive && store.locomotive!.destroy()
        store.locomotive = ref(new Locomotive({ el: locomotiveContainer || undefined }))
    }, [locomotiveContainer])

    return <></>
}

My question is simple: how do you work with dynamic elements popping up, eg dialogs, modals? I have no idea why destroying and isntance and recreating it with an el set to the dialog scrollable container has no reaction ๐Ÿ˜•.

devenini commented 1 year ago

Hey! Have you tried to either add data-lenis-prevent on the dialog popup or to use our workaround?

piscopancer commented 1 year ago

@devenini hey. data-lenis-prevent - I did not know that, where do I use that ๐Ÿค”?

devenini commented 11 months ago

Hey! Sorry for the late reply. To prevent the scroll event from being caught by Lenis, you can add data-lenis-prevent to a div. This is typically used for elements like modals, popups, or nested scroll elements.

tariknh commented 10 months ago

hey looks like you are using nextjs, i made a fix for the v5 where you can just implement this https://github.com/locomotivemtl/locomotive-scroll/issues/506#issuecomment-1753957274

Thats all there is to it. I got it working for app router next 14. If you have questions let me know

tschelovek commented 6 months ago

Hey! Have you tried to either add data-lenis-prevent on the dialog popup or to use our workaround?

Thank you! This helped me to fix scrolling my mobile burger menu. Searching in documentation I've just skipped "Third Party Injected..." so didn't find solution myself.