Skip to content

mmoss/jquery-inview

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published