Skip to content

Instantly share code, notes, and snippets.

@mersy
Last active December 24, 2015 07:09
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 mersy/3af8f8c4aa7904e3f5c0 to your computer and use it in GitHub Desktop.
Save mersy/3af8f8c4aa7904e3f5c0 to your computer and use it in GitHub Desktop.
// ページ下までスクロールしたときにData APIで記事を取得
var bottomLoad = ($("input[name='bottomLoad']").val() === "false") ? false : true;
$(window).on("scroll", function() {
var docHeight = $(document).height();
var scrollPos = $(window).height() + $(window).scrollTop();
// ページ下から50pxの範囲が表示されたら読み込み。loadFinishedがtrueの場合は読み込まない。
if (bottomLoad && !loadFinished && (docHeight - scrollPos) < 50) {
bottomLoad = false;
params.offset = params.offset + params.limit;
getApiEntries (1, params, "");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment