question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Div doesn't show with mobile disable

See original GitHub issue

This is:

Bug

Specifications

  • AOS version: 2.3.4
  • OS: Windows
  • Browser: Chrome

Expected Behavior

Remove animation for data-aos with config disable: mobile

Actual Behavior

Div with data-aos doesn’t show if mobile is disabled

Steps to Reproduce the Problem

in nuxt plugin AOS.init({ disable: 'mobile})

in html <div data-aos="fade-in"></div>

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

19reactions
benhondacommented, Jul 5, 2021

A bit late to the party but here’s the workaround I’m using to disable AOS animation on smaller screen sizes only:

First, disable animation on the screen size of your choice in the AOS.init function:

AOS.init({
  disable: window.innerWidth < 768,
  ...
});

When you set the ‘disable’ prop it seems AOS will add pointer-events: none and opacity: 0 to your data-aos=* elements, so you need to overwrite the AOS styles in a media query.

For example, if you’re using data-aos="fade-up", your custom CSS might look like this:

@media screen and (max-width: 768px) {
  [data-aos] {
    pointer-events: auto !important;
  }

  html:not(.no-js) [data-aos^=fade][data-aos^=fade] {
    opacity: 1 !important;
  }

  html:not(.no-js) [data-aos=fade-up] {
    transform: none !important;
  }
}
3reactions
fahedusmanranacommented, Mar 22, 2021

Hi Guys, I was having the same issue. It was working fine on Desktop but the animation was not working on mobile. (iPhone + Safari Browser) I was testing on it. After researching I found few solutions like adding mobile disabled and overflow for html or body, nothing worked for me. Following solution worked for me. Instead of adding init function in a separate JS file, I had to add the following in the footer of my html file and it started working for me.

<script>
$(function() {
    AOS.init({
        once: true // this one if you want to load animation once else you can remove it
    });
});
</script>
Read more comments on GitHub >

github_iconTop Results From Across the Web

DIVs not Displaying as Block on Mobile - css - Stack Overflow
your problem is not that the divs won't display as blocks, but that some of your blocks are wider than the view-port. Share....
Read more >
Div doesn't get hidden on mobile - CodeProject
Problem is that I want to disable user to scroll the website horizontally by himself. With 'overflow:hidden' it works for desktop size (if...
Read more >
Display property - Bootstrap
Quickly and responsively toggle the display value of components and more with our display utilities. Includes support for some of the more common...
Read more >
CSS- Div- Be Careful When You Size Your Divs
Be Careful When You Size Your Divs · Visible - Content may appear outside the DIV. · Hidden - Extra content doesn't display...
Read more >
4 reasons your z-index isn't working (and how to fix it)
1. Elements in the same stacking context will display in order of appearance, with latter elements on top of former elements. · 2....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found