Created
April 21, 2015 15:47
-
-
Save chadspencer/2a5ccf6844549ca15214 to your computer and use it in GitHub Desktop.
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
$(document).on('click', 'section.sets a.ajax', function() { | |
var href = $(this).attr('href'); | |
$.ajax({ | |
url: href, | |
success: function(data){ | |
console.log(data); | |
$('section.sets div.items').append($(data).find('section.sets div.items').html()); | |
var href = $(data).find('section.sets a.ajax').attr('href'); | |
$('section.sets a.ajax').attr('href', href); | |
$(window).on('scroll', onScroll); | |
} | |
}); | |
history.pushState({}, '', '/lookbook/'); | |
return false; | |
}); | |
function onScroll(){ | |
if($(window).scrollTop() + $(window).height() > $(document).height() - 200) { | |
$(window).off('scroll'); | |
$('section.sets a.ajax').trigger('click'); | |
} | |
} | |
$(window).scroll(onScroll); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment