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.

Css scroll snap compatibility

See original GitHub issue

This is:

  • Bug

Specifications

  • AOS version: 2.3.4
  • OS: MacOS
  • Browser: Chrome, Firefox and Safari 12.0

Expected Behavior

When i use the css scroll-snap-type: mandatory, aos-animate class must be added to the node

Actual Behavior

aos-animate class is NOT added to the node and animation are not triggered

Steps to Reproduce the Problem

  1. Put this css on a container
height: 100vh;
overflow-y: scroll;
scroll-snap-points-y: repeat(100vh);
scroll-snap-destination: 0 0;
scroll-snap-type: y mandatory;
scroll-snap-type: mandatory;

This css on child :

scroll-snap-align: start;
height: 100%;
  1. Install aos
  2. And add data-aos=“fade-up” on the childs
  3. AOS animation doesn’t trigger

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:8
  • Comments:18

github_iconTop GitHub Comments

4reactions
rajileshcommented, Oct 29, 2021

Added this and worked.

const aosAnimation = document.querySelectorAll('[data-aos]');
observer = new IntersectionObserver((entries) => {
  entries.forEach(entry => {
    if (entry.intersectionRatio > 0) {
      entry.target.classList.add('aos-animate');
    } else {
      entry.target.classList.remove('aos-animate');
    }
  });
});
aosAnimation.forEach(aosObject => {
  observer.observe(aosObject);
});
1reaction
Gokul1995commented, Dec 17, 2021

aos doesnot work with overflow-y: scroll; property. If you want to use overflow property you need to refresh AOS on scroll of the window event, which can be triggered as

document.addEventListener('scroll', (event) => { AOS.refresh();}, {capture: true, passive: true,})

Note to pass capture property else event will not triggred on oveflow property.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"scroll-snap" | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
Cross Browser Compatibility Score of CSS Scroll Snap
CSS Scroll Snap on Chrome is fully supported on 69-106, partially supported on None of the versions, and not supported on 4-68 Chrome...
Read more >
scroll-snap-type - CSS: Cascading Style Sheets | MDN
The visual viewport of this scroll container will rest on a snap point if it isn't currently scrolled. That means it snaps on...
Read more >
Practical CSS Scroll Snapping
Browser support for CSS scroll snapping has improved significantly since it was introduced in 2016, with Google Chrome (69+), Firefox, Edge, ...
Read more >
Well-controlled scrolling with CSS Scroll Snap - web.dev
CSS Scroll Snap allows web developers to create well-controlled scroll experiences by declaring scroll snapping positions.
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