今天终于学会了下拉刷新,上拉刷新

今天终于学会了下拉刷新,上拉刷新

<div id="megBox">

  <div id="refreshbar" >下拉刷新。。</div>

</div>

var touchPoint={

      Y:0,

      Loading:false

}

function InitTouch(){

  var box=document.getElementById("megBox");

  box.addEventListener("touchstart",function(target){

        touchPoint.Y=target.targetTouches[0].pageY;

  },false);

  box.addEventListener("touchmove",function(target){

        if(!touchPoint.Loading){

           var distance=target.targetTouched[0].pageY-touchPoint.Y;

           if(distance>100){

              touchPoint.Loading=true;

              $("#refreshbar").height(30);

              setTimeout(function(){

              //刷新方法

               },2000);

           }

        }

  },false);

}