A plain javascript library (~1kb) that adds classes to elements in viewport. This Repository also includes a jQuery version.
<script src="dist/in-viewport-class.js"></script>include this script after the jQuery library:
<script src="dist/jquery.in-viewport-class.js"></script>bower install in-viewport-classnpm install --save in-viewport-classadd i-v class to every element you want to observed.
<div class="element i-v"></div>in-viewportadded when the element enter the viewport, removed when the element left the viewportwas-in-viewportadded when the element left the viewportin-viewport-onceadded when the element enter the viewport first, newer removed
www.neuedaten.de/in-viewport-class/
or have a look at example-plain-javascript.html or example.html