appcan 上/下拉刷新函数的一个简单封装

  1. function dorpDownUpdate(){
  2.     alert('drop down update success');
  3.     uexWindow.resetBounceView('0');
  4. }
  5. function pullUpUpdate(){
  6.     alert('pull up update success');
  7.     uexWindow.resetBounceView('1');
  8. }
  9. function setPageBounce(downcb, upcb){
  10.         var s = ['0', '0'];
  11.         uexWindow.onBounceStateChange = function (type,status){
  12.                 if(downcb && type==0 && status==2) downcb();
  13.                 if(upcb && type==1 && status==2) upcb();
  14.         }
  15.         uexWindow.setBounce("1");
  16.         if(downcb){
  17.                 s[0] = '1';
  18.                 uexWindow.setBounceParams(0,
  19.                 {"imagePath":"res://loading.png","textColor":"#aaa","levelText":"xxxx","pullToReloadText":"下拉刷新","releaseToReloadText":"释放刷新","loadingText":"加载中,请稍等"});
  20.                 uexWindow.notifyBounceEvent("0","1");
  21.         }
  22.         if(upcb){
  23.                 s[1] = '1';
  24.                 uexWindow.setBounceParams(1,
  25.                 {"imagePath":"res://loading.png","textColor":"#aaa","levelText":"xxxx","pullToReloadText":"上拉刷新","releaseToReloadText":"释放刷新","loadingText":"加载中,请稍等"});
  26.                 uexWindow.notifyBounceEvent("1","1");
  27.         }
  28.         uexWindow.showBounceView("0","#FFF",s[0]);
  29.         uexWindow.showBounceView("1","#FFF",s[1]);
  30. }
调用方式: setPageBounce(dorpDownUpdate,pullUpUpdate);

你可能感兴趣的:(下拉刷新,appcan,上拉刷新)