Skip to content

Latest commit

 

History

History
33 lines (21 loc) · 1 KB

README.md

File metadata and controls

33 lines (21 loc) · 1 KB

jQuery.inView Plugin(ish)

Build Status

This is a simple plugin I've thrown together for my blog/personal site, where I use it to defer the loading of Disqus comments. This script can be used to defer the loading of third party plugins, scripts, or anything else you want to do once elements have come into view.

The plugin uses jQuery's Deferred Object API.

Documentation

$.inView()

  • The $.inView() function, when called will return a new jQuery.Deferred object that will resolve once all elements in the jQuery object have come into view.

Usage Example

$.when($('#myElement').inView()).then(function($el){
  alert($el.attr('id') + ' is now in view');
});

Or

$('#myElement').inView(function(){
  alert($(this).attr('id') + ' is now in view');
});

Dependencies