Skip to content

Instantly share code, notes, and snippets.

@dustintheweb
Last active December 16, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustintheweb/5447407 to your computer and use it in GitHub Desktop.
Save dustintheweb/5447407 to your computer and use it in GitHub Desktop.
A skrollr.js based lazyloader
// >> Skrollr.js LazyLoader >>>>>>>>>>>>>>>>
// prereq: throttle: https://github.com/cowboy/jquery-throttle-debounce
// note: throttle: when you want to receive constant data from the user
// debounce: when you want to wait for the user to be done
$(function(){
var sec1 = $('#section-1'),
sec2 = $('#section-2'),
sec3 = $('#section-3');
$(window).on('scroll', $.throttle(150,
function(){
if (skrollr.init().getScrollTop() > 4000) {
sec1.find('img').css({'display':'block'});
}
if (skrollr.init().getScrollTop() > 8000) {
sec2.find('img').css({'display':'block'});
}
if (skrollr.init().getScrollTop() > 12000) {
sec3.find('img').css({'display':'block'});
}
})
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment