Using the function getBoundingClientRect() we can easily figure out whether or not an element is inside or outside of the viewport.
Final code here: https://codepen.io/andreaswik/pen/dxVMvj
Any questions or thoughts, let me know in the comments!
#javascript #webdevelopment #webdev