aos icon indicating copy to clipboard operation
aos copied to clipboard

Div doesn't show with mobile disable

Open filippodicostanzo opened this issue 4 years ago • 8 comments

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>

filippodicostanzo avatar Dec 07 '20 20:12 filippodicostanzo

I have the same problem.

Using AOS.init({ disable: 'mobile}) makes that DIVs where animations are used don't display at all, even on desktop size. I have only white space there.

Taszal avatar Dec 22 '20 09:12 Taszal

I'm having the same problem for elements loaded async after page loaded. Even a AOS.refresh (); does not solve it, if I refresh after new elements are appended.

ToHe86 avatar Jan 22 '21 17:01 ToHe86

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>

fahedusmanrana avatar Mar 22 '21 06:03 fahedusmanrana

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;
  }
}

benhonda avatar Jun 15 '21 19:06 benhonda

I face this mobile sections going blank issue in react.js.

What I was doing was intializing aos animation in App.js file which is correct.

but to solve this problem for mobile I ended up initializing aos into separate components inside useEffect instead of App.js.

This might solve your problem of section going blank in mobile.

do following:- useEffect(() => { AOS.init({ duration: 2400, disable: "mobile", }); }, [])

Vijay-navale avatar Jan 02 '22 20:01 Vijay-navale

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>

Finally a stupid solution that worked

TechInjectIndia avatar Aug 20 '22 09:08 TechInjectIndia

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,
  ...
});

...

You're a lifesaver! Thanks!

mazyn avatar Sep 09 '22 20:09 mazyn

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;
  }
}

Thank you, Actually this is what worked for me:

@media screen and (max-width: 767px) {
  [data-aos] {
    pointer-events: auto !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

hassanedelbi avatar Dec 12 '22 19:12 hassanedelbi