Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where to set up disabling animations on mobile #13

Open
jchabrowski opened this issue Feb 8, 2021 · 1 comment
Open

Where to set up disabling animations on mobile #13

jchabrowski opened this issue Feb 8, 2021 · 1 comment

Comments

@jchabrowski
Copy link

As here I would like to set up sal to disable animations below ceratin viewport (for example 768px). Where should I include it in a gatsby project?

I feel like it should be placed inside gatsby-browser.js, but then "sal is not defined".

Example code, copied from the link provided above.

const animation = sal();

const switchAnimations = () => {
  if (window.innerWidth < 768) {
    animation.reset({
      selector: 'animated-element',
      once: true,
    });
  } else {
    animation.reset({
      // some other options
    });
  }
};

switchAnimations();
window.addEventListener('resize', switchAnimations);
@TheDevDoctor
Copy link

I agree this would be a useful feature, I'd like to disable the animations on mobile devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants