Can anyone please tell me how to turn of animations of my page when it’s being viewed by a mobile device?
I’m using aos library for css to add some animation to my page. But I want to turn that animation off on mobile devices. Any help on that regard will be greatly appreciated. Thanks!
Link of the library: https://michalsnik.github.io/aos/
You can also disable the animations on certain devices or under certain conditions using the disable key and setting its value to a device type like mobile, phone or tablet. Alternatively, you can also disable the library using a function. In this Pen, when the screen is smaller than 800px, AOS animations are disabled using the function above:
But if you're new to Android or just upgraded to a new phone and forgot about this, here's what you do: Make sure developer options are enabled. Go to Settings > Developer options, and scroll down to Window animation scale, Transition animation scale, and Animator duration scale. Tap on each of the animation options and turn them off.
Start by heading over to Settings. Scroll all the way down and tap on Developer options. Once you are in the Developer options, scroll down until you find the following. Tap on them one by one and choose Animation off. Once you are done with that you can simply go back and start using your device.
There are many libraries to make this task easier for us. AOS, also called Animate on Scroll, is one such library and it does exactly what its name suggests: it lets you apply different kinds of animations to elements as they scroll into view.
Maybe you want to do it with CSS but it can be easy with JS. You can use optional settings object on your JS file where you initialize AOS like this:
AOS.init({disable: 'mobile'});
Here you can use following values: 'phone', 'tablet', 'mobile', boolean, expression or function
For more options check https://github.com/michalsnik/aos
You can use this js to specify when exactly you want to disable it.
AOS.init({
disable: function() {
var maxWidth = 800;
return window.innerWidth < maxWidth;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With