michalsnik / aos

Animate on scroll library
MIT License
26.63k stars 2.58k forks source link

[Question] How to change data-aos-offset on phones/tablets? #469

Open Ahearys opened 5 years ago

Ahearys commented 5 years ago

This is:

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)

jcbbuller commented 5 years ago

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

Murkrow02 commented 5 years ago

I have this problem too

TNHSAesop commented 5 years ago

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'

    });
  });
oli-kester commented 3 years ago

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