欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

iscroll-probe实现下拉刷新和下拉加载效果

程序员文章站 2022-06-03 13:57:46
需要注意的是外部wrapper的高度,以及all的高度,须是>100%。 附加一个css3 的loading .dengl-spinner {...

需要注意的是外部wrapper的高度,以及all的高度,须是>100%。

附加一个css3 的loading

.dengl-spinner {
  width: 0.682rem;
  height: 0.682rem;
  position: relative;
  position: absolute;
  z-index: -1;
  left: 50%;
  margin-left: -0.341rem;
  top: 2.5rem;
}
.dengl-spinner1{
  width: 0.682rem;
  height: 0.682rem;
  position: relative;
  position: fixed;
  z-index: -1;
  left: 50%;
  margin-left: -0.341rem;
  bottom: 1.5rem;
}
.dengl-cube1, .dengl-cube2 {
  background-color: #f2513f;
  width: 0.682rem;
  height: 0.682rem;
  position: absolute;
  top: 0;
  left: 0;
  -webkit-animation: cubemove 1.8s infinite ease-in-out;
  animation: cubemove 1.8s infinite ease-in-out;
}

.dengl-cube2 {
  -webkit-animation-delay: -0.9s;
  animation-delay: -0.9s;
}

@-webkit-keyframes cubemove {
  25% {
    -webkit-transform: translatex(1rem) rotate(-90deg) scale(0.5)
  }
  50% {
    -webkit-transform: translatex(1rem) translatey(1rem) rotate(-180deg)
  }
  75% {
    -webkit-transform: translatex(0px) translatey(1rem) rotate(-270deg) scale(0.5)
  }
  100% {
    -webkit-transform: rotate(-360deg)
  }
}

@keyframes cubemove {
  25% {
    transform: translatex(1rem) rotate(-90deg) scale(0.5);
    -webkit-transform: translatex(1rem) rotate(-90deg) scale(0.5);
  }
  50% {
    transform: translatex(1rem) translatey(1rem) rotate(-179deg);
    -webkit-transform: translatex(1rem) translatey(1rem) rotate(-179deg);
  }
  50.1% {
    transform: translatex(1rem) translatey(1rem) rotate(-180deg);
    -webkit-transform: translatex(1rem) translatey(1rem) rotate(-180deg);
  }
  75% {
    transform: translatex(0px) translatey(1rem) rotate(-270deg) scale(0.5);
    -webkit-transform: translatex(0px) translatey(1rem) rotate(-270deg) scale(0.5);
  }
  100% {
    transform: rotate(-360deg);
    -webkit-transform: rotate(-360deg);
  }
}

上下两个

<div class="dengl-spinner" style="top:17rem">
  <div class="dengl-cube1"></div>
  <div class="dengl-cube2"></div>
</div>

<div class="dengl-spinner1" style="bottom:3rem;">
  <div class="dengl-cube1"></div>
  <div class="dengl-cube2"></div>
</div>

下面是正文

 <style>
    #wrapper {
      position: absolute;
      width: 100%;
      z-index: 1;
      top: 16.1rem;
      bottom: 2rem;
      left: 0;
      overflow: hidden;
    }

    #all {
      position: absolute;
      z-index: 1;
      -webkit-tap-highlight-color: rgba(0,0,0,0);
      width: 100%;
      -webkit-transform: translatez(0);
      -moz-transform: translatez(0);
      -ms-transform: translatez(0);
      -o-transform: translatez(0);
      transform: translatez(0);
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      -webkit-text-size-adjust: none;
      -moz-text-size-adjust: none;
      -ms-text-size-adjust: none;
      -o-text-size-adjust: none;
      text-size-adjust: none;
      background: #fff;
      min-height: 100.5%;
    }
  </style>

 <div id="wrapper">
            <ul id="all"></ul>
  </div>

var index = 2, size = 10;
    $(function () {
      $.qr.ajax('usercenter/myjdandml', { token: $.qr.gettoken() }, function (d) {
        var vm1 = new vue({
          el: '#top_1',
          data: {
            money: d.data_single.money
          }
        });
        var vm2 = new vue({
          el: '#top_2',
          data: {
            earnings: d.data_single.earnings,
            has_catfood: d.data_single.has_catfood,
            not_catfood: d.data_single.not_catfood
          }
        });
      });
      var myscroll = new iscroll('#wrapper', {
        mousewheel: false,
        bouncetime: 1000,
        bouncelock: true,
        probetype: 3
      });
      var handle = 0;
      myscroll.on('scroll', function () {
        if (this.y > 50) {
          handle = 1;
        } else if (this.y < (this.maxscrolly - 50)) {
          handle = 2;

        };
      });
      myscroll.on('scrollend', function () {
        if (handle == 2) {
          add(index, size);
        } else if (handle == 1) {
          add(1, size);
        }
        handle = 0;
        myscroll.refresh();
      });
      document.addeventlistener('touchmove', function (e) { e.preventdefault(); }, false);
      add(1, size);
    });
    function add(pindex, psize) {
      $.qr.ajax('usercenter/maoliangrecordlist',
        { token: $.qr.gettoken(), pagesize: psize, pageindex: pindex }, function (d) {
          var _h = '';
          if (pindex != 1 && d.data_list.data_list.length > 0) index++;
          if (d.data_list.data_list.length == 0) return false; 
          $(d.data_list.data_list).each(function (i, j) {
            _h += '<li>';
            _h += '<div class="info" style="left: 10%">' + j.name + '</div>';
            _h += '<div class="info">' + j.num + '</div>';
            _h += '<div class="info">' + j.time + '</div>';
            _h += '</li>';
          });
          if (pindex == 1) $('#all').empty();
          $('#all').append(_h);

        }, false);

    }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。