Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 1000 Bytes

README.md

File metadata and controls

45 lines (34 loc) · 1000 Bytes

$(selector).inViewport()

Lightweight function writen in javascript that add the function inViewport to jquery.

Usage

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

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])

Require

<script src="js/jquery.js"></script>
<script src="js/inviewport.min.js"></script>