Aos: [Question] How to change data-aos-offset on phones/tablets?

Created on 19 Apr 2019  路  4Comments  路  Source: michalsnik/aos

This is:

  • Question

Specifications

  • AOS version: 2.3.1
  • OS:
  • Browser:

I want to change data-aos-offset for smaller screens, because it doesn't line up as it's supposed to (e.g. content that should animate first, animates after content that should animate second, on mobile screens)

Most helpful comment

I just hacked it with the window's height. Note that this doesn't take into account browser resizing which would likely require a destroy/re-init call with an updated height. My site doesn't get enough traffic for me to care about the occasional exit that might cause though. If someone's more motivated than me to tackle that, please post your code!

offset: (jQuery(window).height() * .25)

full init that looks pretty good to me

    AOS.init({
      offset: (jQuery(window).height() * .25),
      delay: 400,
      duration: 700,
      easing: 'ease-out-back',
      anchorPlacement: 'bottom-center'

    });
  });

All 4 comments

Anyone find an answer to this? I'm having the same issue.

I have this problem too

I just hacked it with the window's height. Note that this doesn't take into account browser resizing which would likely require a destroy/re-init call with an updated height. My site doesn't get enough traffic for me to care about the occasional exit that might cause though. If someone's more motivated than me to tackle that, please post your code!

offset: (jQuery(window).height() * .25)

full init that looks pretty good to me

    AOS.init({
      offset: (jQuery(window).height() * .25),
      delay: 400,
      duration: 700,
      easing: 'ease-out-back',
      anchorPlacement: 'bottom-center'

    });
  });

I just hacked it with the window's height. Note that this doesn't take into account browser resizing which would likely require a destroy/re-init call with an updated height. My site doesn't get enough traffic for me to care about the occasional exit that might cause though. If someone's more motivated than me to tackle that, please post your code!

offset: (jQuery(window).height() * .25)

full init that looks pretty good to me

    AOS.init({
      offset: (jQuery(window).height() * .25),
      delay: 400,
      duration: 700,
      easing: 'ease-out-back',
      anchorPlacement: 'bottom-center'

    });
  });

This works great, thanks! Was worried I'd have to stop using AOS due to mobile issues.

A pure-JS version to solve this issue alone -

AOS.init({ offset: (window.innerHeight * .3) })

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timotheegoguely picture timotheegoguely  路  3Comments

webcredo picture webcredo  路  3Comments

noisypope picture noisypope  路  4Comments

webdevnerdstuff picture webdevnerdstuff  路  3Comments

tyler-insight picture tyler-insight  路  5Comments