O'Reilly logo

Web Design Blueprints by Benjamin LaGrone

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Collecting the moving elements

If the previous condition is true, we need to collect the SVG icons in an array and then get the class of each one. Each class will behave differently. Go through another loop that gathers the current row element's child elements identified by the tag name I. And then loop through each of those children's list of classes collected by the classList method. I will show you how this will look before I tell you what we will do with it. Take a look at the loop in a loop in a loop in this code sample:

 function getMovingElements(callback){ for (var i = 0;i<document.getElementsByClassName("row").length; i++) { if((window.pageYOffset + (window.innerHeight)) > document.getElementsByClassName("row")[i].offsetTop && (window.pageYOffset) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required