jQuery plugin allowing you to specify a callback to execute when an element is scrolled into view. The plugin is less than 1kb unminified and uses jQuery's Deferred Object API
JavaScript CoffeeScript Ruby
Latest commit f9abb5d Mar 24, 2013 mmoss Add CI build status image to README.md
Permalink
Failed to load latest commit information.
test
.gitignore Add Travis CI config & minor updates Mar 25, 2013
.travis.yml Add Travis CI config & minor updates Mar 25, 2013
LICENSE.txt
README.md Add CI build status image to README.md Mar 25, 2013
Rakefile
example-usage.html
jquery.inview.coffee Add Travis CI config & minor updates Mar 25, 2013
jquery.inview.js Add Travis CI config & minor updates Mar 25, 2013
jquery.inview.min.js Add Travis CI config & minor updates Mar 25, 2013
package.json Add Travis CI config & minor updates Mar 25, 2013

README.md

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