Lightweight function writen in javascript that add the function inViewport to jquery.
Just take an exemple for this element that have an item
id.
<div id="item">Item 1</div>
To test if the is visible on the screen use $("#element").inViewport();
:
<script>
$(function () {
if($('#items').inViewport()){
// code if the element is visible
console.log('items is visible');
}
});
</script>
Options could be either configured in the library :
var defaultDirection = 'both'; //both,vertical,horizontal
var defaultFull = false ; // true, false
or we can specify the direction and the testing region [full|partial] of an element when you're using the function:
$('#selector').inViewport('vertical',false); //(['vertical'|'both'|'horizontal'],[false|true])
<script src="js/jquery.js"></script>
<script src="js/inviewport.min.js"></script>