Skip to content
Advertisement

Why IntersectionObserver is not applying the classes?

I’m following a tutorial about IntersectionObserver, but I can’t seem to get it to work… I’m trying to apply an animation on the elements that are visible in the viewport. I will paste the JS code here and the full example with html and css is here: https://codepen.io/cucurutcho/pen/KKWRrov

JavaScript

Any help is greatly appreciated! Thanks so much guys

Advertisement

Answer

You’re not targeting the classes, you’re overwriting the text content of the CSS animation property as described here.

You need classList instead:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement