onScreen - A jQuery plugin that does stuff to elements when they enter or leave the viewport

onScreen is a jQuery plugin that does stuff when the matched elements are visible (as inside the viewport).

 

The basic form $('element').onScreen(); will only toggle the onScreen class on the matched elements. This is optimal for CSS animations. You can set the tolerance parameter and allow the elements to enter the viewport certain amount of pixels before doing anything.

 

onScreen also has two methods called doIn() and, obviously, doOut() that will execute when the matched elements enter and leave the viewport. It's pretty straight forward. And This plugin can work as a lazy loader for your images, that way you can minimize unnecessary httprequests of content that isn't even visible.

 

w10schools
2014-05-01 08:58:07
Comments
Leave a Comment

Please login to continue.