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

How to disable animations on smaller screens? #72

Closed
gr2m opened this issue Aug 25, 2014 · 10 comments
Closed

How to disable animations on smaller screens? #72

gr2m opened this issue Aug 25, 2014 · 10 comments

Comments

@gr2m
Copy link

gr2m commented Aug 25, 2014

I hope I could just add this CSS

@media (max-width: 480px) {

  /* disable scroll reveal */
  [data-sr] {
    -webkit-tranform: none !important;
    transform: none !important;
  }
}

but it didn't do the trick (in latest Chrome). Do you have a suggestion?

@getimo
Copy link

getimo commented Aug 25, 2014

Same problem here. On mobile the animations are annoying because they're triggered when the scroll has finished which leads to blank screens for a while - on iOS at least.

@jlmakes
Copy link
Owner

jlmakes commented Sep 2, 2014

This has come up a few times, and will be definitely be supported in v2.0.0.

Duplicate of #32

@jlmakes jlmakes closed this as completed Sep 2, 2014
@maltheluda
Copy link

@julianlloyd Julian, thank you, dude! 🍻

@jlmakes
Copy link
Owner

jlmakes commented Oct 18, 2014

@getimo @gr2m @maltheluda This is now baked in!

window.sr = new scrollReveal({ mobile: false })

@thulioph
Copy link

thulioph commented Nov 4, 2014

I'm using window.sr = new scrollReveal({ mobile: false }) and the animations don't disable on iPad, any idea? @julianlloyd 😟

@jlmakes
Copy link
Owner

jlmakes commented Nov 4, 2014

@thulioph I didn’t actually realize this, but…

pulled straight from http://detectmobilebrowsers.com/about (where the regex comes from)

screen shot 2014-11-04 at 11 48 52 am

So in order to include tablets as mobile, add |android|ipad|playbook|silk to the first regex on line 517

@thulioph
Copy link

Thanks @julianlloyd, but don't resolve my problem.
I'm having a little break on project, when returning i see again ✋

@jlmakes
Copy link
Owner

jlmakes commented Nov 18, 2014

I see.

Well, I think I’ll be adding support for tablets in the near future. So perhaps by then, I’ll have prepared a solution for you.

@deepakya
Copy link

deepakya commented Aug 23, 2016

Is there any way to disable ScrollReveal animations on mobile devices but enable them on Tablets such or devices with viewport width of more than 992px ?

@jlmakes
Copy link
Owner

jlmakes commented Aug 23, 2016

@deepakya You can use window.matchMedia (browser support) to check your media queries with JavaScript, and configure ScrollReveal as you like. I haven’t tested this, but I believe something like this should get you pretty close...

Example:

var mq = window.matchMedia( "(min-width: 992px)" );
var sr = new ScrollReveal();
var isMobile = sr.tools.isMobile();

// ScrollReveal should proceed if we’re not mobile,
// or if we’re mobile with a matching minimum width. 
if (!isMobile || (isMobile && mq.matches)) {
  sr.reveal('.foo', { reset: true });
  // etc...
}

The sr.tools are used internally, but aren’t documented. In the above example, I use them to check and store whether or not the current device is mobile.

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

No branches or pull requests

6 participants