Skip to content

inViewport is a simple jquery plugin to test if an element is visible on the screen, usage : $("#element").inViewport();

Notifications You must be signed in to change notification settings

xakiru/inViewport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

$(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>

About

inViewport is a simple jquery plugin to test if an element is visible on the screen, usage : $("#element").inViewport();

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published