Last active
December 16, 2015 14:19
-
-
Save dustintheweb/5447407 to your computer and use it in GitHub Desktop.
A skrollr.js based lazyloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// >> 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