總體向上移動,循環移動一樣的數據

總體向上移動,循環移動一樣的數據css

var  lis,//一次向ul裏添加的li
    bottomUl=0,//ul向上移的距離
    ulNum=0;//插入ul的個數
$.ajax({
    url: "./equpment/lastInfo",
    dataType: 'json',
    success: function (results) {
        lis=results;
      liAppengToUl(results);
      moveUl();
    }
});
function liAppengToUl(results){ //向ul中插入li,讓ulNum爲1;
    var frag=document.createDocumentFragment();
    $(results).each(function(index,car){
        var li='<li class="'+ulNum+'">Id爲'+car.equpid+'的車輛'+car.equpname+'在'+car.gps_date+'耕做了'+parseFloat(car.area/666.6667).toFixed(2)+'畝地</li>';
        $(frag).append(li);
    });
    $("#ul").append(frag);
    ulNum+=1;
};
function moveUl(){
    bottomUl+=10;//向上移動的距離                
  $("#ul").animate({bottom:bottomUl},500); var time=setTimeout(moveUl, 500);//0.5秒向上移一次ul,0.5秒移bottomUl的距離 if($("#ul").height()!=0){ var height=$("#ul").height(); } if(ulNum>=3){ $("li.0").remove();//移除第一次添加的全部li ulNum=0; liAppengToUl(lis);//讓ulNum爲0,會有一段空白,因此先添加lis } if(parseInt($("#ul").css(
'bottom'))>=(height-window.screen.height*0.9)){ //若是ul向上移的長度大於ul的高度(lis的高度)減去屏幕顯示的高度,插入一次lis liAppengToUl(lis); } }
相關文章
相關標籤/搜索