Feed on
Posts
Comments
Email訂閱
  1. 安裝lazyload plugin for jquery to defer loading image
  2. 設計當滾動到頁面底部時才動態載入內容

var jstart =0;
var jlimit =10;
var scrolleventlock =false;

jQuery(document).ready(function($){
if (navigator.platform == "iPad") return;
jQuery("img").lazyload({
effect:"fadeIn",
placeholder: "images/grey.gif"
});

function lastAddedLiveFunc()
{
if((jlimit == 0) || (scrolleventlock)) return;
scrolleventlock =true;

var ajaxurl='ajaxserver/getarticles.home.jq.php';

var showdiv = 'divcontent';
$('div#lastPostsLoader').html('');
$.ajax({
url: ajaxurl,
data: {start: jstart, limit: jlimit},
success: function(response) {
if(response != "")
{
jstart += jlimit;
$('#'+showdiv).html($('#'+showdiv).html() + response);
}
else jlimit = 0;
scrolleventlock =false;
$('div#lastPostsLoader').empty();

}
});
};

$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
lastAddedLiveFunc();
}

});

});

相關文章

留言區