locomotivemtl / locomotive-scroll

🛤 Detection of elements in viewport & smooth scrolling with parallax.
https://locomotivemtl.github.io/locomotive-scroll
MIT License
7.56k stars 1.11k forks source link

It doesn't work on my Android mobile #440

Closed cyrillebrotto closed 2 years ago

cyrillebrotto commented 2 years ago

Hello I tested this code. https://codepen.io/Cyrille-Brotto/pen/zYRVoBa It works well on firefox and chrom on desktop. It doesn't work on my Android mobile. Do you have an idea? Thank you

mmilde commented 2 years ago

I had the same problem, but now it works on all mobile. Maybe you should try with this setup:

window.addEventListener("load", () => {
const scroll = new LocomotiveScroll({
    el: document.querySelector('[data-scroll-container]'),
    smooth: true,
    scrollFromAnywhere: true,
    multiplier: 1,
    getDirection: true,
    reloadOnContextChange: true,
    touchMultiplier: 3,
    smoothMobile: 0,
    smartphone: {
        smooth: !0,
        breakpoint: 766
    },
    tablet: {
        smooth: !0,
        breakpoint: 1010
    },
});
cyrillebrotto commented 2 years ago

Thank you but unfortunately it still doesn't work on my Android mobile :-( https://codepen.io/Cyrille-Brotto/pen/zYRVoBa

mmilde commented 2 years ago

In your example I don't see data-scroll-section anywhere. Not sure that this is the problem, but I think you should stick to the layout shown in the documentation https://github.com/locomotivemtl/locomotive-scroll#smooth

cyrillebrotto commented 2 years ago

I added some data-scroll and datascroll-section. I changed smoothMobile to true. Now it works on desktop and mobile :-) Thank you very much