Is there a way to add a class when the element that I want to apply the class to comes into the viewport? Or when the bottom of the screen is a certain distance past the top of
You're on the right track, I think if you use the scroll event with a function such as the answer to this similar question:
Check if element is visible after scrolling
Hope that helps :)