When to fetch more content on infinite scroll?
I'm building out an infinite scrolling feature for my site and am debating 开发者_开发知识库at what scroll point to inject more content into the page. I've seen some that perform the request at a fixed pixel distance from the bottom of the document, and others that feel more percentage based. What do large sites like Tumblr, Facebook, Pinterest, etc. do? Are there different use cases between fixed pixel distance and percentage? Here's my code:
// 20%
var scrollPoint = ($(document).height()/5);
if($(window).scrollTop() >= $(document).height() - $(window).height() - scrollPoint) {
console.log('Load more goodness');
}
Edit: On re-examining Facebook, it almost looks like they have a 'hot zone' where they pull in more content. If you use the mouse to scroll to the bottom you don't get an auto fetch of content.
I would imagine a fixed pixel distance is a great idea, since as you add more content, the 20% mark would probably include more and more information. Depending on your content, I think it could even end up in a feedback loop.
Since the "tick" of the mouse's scroll wheel is independent upon window size, I think that the triggering distance should also be static.
I don't really know what to say. Does it make a difference? As long as the user doesn't hit the bottom of the page, I don't think it matters.
Why not use an existing JQuery plugin like this one rather than writing it yourself? http://www.infinite-scroll.com/infinite-scroll-jquery-plugin/
精彩评论