I believe this is possible. You can use <name>
or <id>
tags similar to the way you want to direct someone to a certain part of a page.
I would use those to determine whether an element is in the viewport or outside of it.
If you are okay with using a plugin you should go with the JQuery isInViewport
plugin :
https://plugins.jquery.com/isInViewport/
You can also take a look at the raw code and change it to your liking.