electerious / basicScroll

Standalone parallax scrolling for mobile and desktop with CSS variables.
https://basicscroll.electerious.com
MIT License
3.63k stars 148 forks source link

Disable basicScroll on mobile devices? #20

Closed MonsterDeveloper closed 6 years ago

MonsterDeveloper commented 6 years ago

Is there any option to disable basicScroll on mobile devices?

electerious commented 6 years ago

No, but there're multiple ways to do what you're looking for:

a) Use media-queries in your CSS to disable the use of animated CSS properties b) Never call .start on mobile devices c) Call .stop() on mobile devices

I recommend to use the first option.

FynnZW commented 6 years ago

I noticed that for iOS Safari, I have to destroy the instance. Not calling start is not enough:

 // init above
  if (window.innerWidth >== 640) {
    parallaxElements.forEach((parallaxElement) => parallaxElement.start())
  } else {
    parallaxElements.forEach((parallaxElement) => parallaxElement.destroy())
  }