weui苹果手机滚动加载不兼容问题

转自:https://www.cnblogs.com/mr-shb/p/11584235.html

源代码:(1.0.1版本)

复制代码
Infinite.prototype.scroll = function() {
   var container = this.container;
   var offset = container.scrollHeight() - ($(window).height() + container.scrollTop());
   if(offset <= this.distance) {
     container.trigger("infinite");
   }
}
复制代码

修改:

复制代码
Infinite.prototype.scroll = function() {
  var container = this.container;
  var tagName = container[0].tagName.toUpperCase()
    var scrollTop
    if (tagName === 'BODY' || tagName === 'HTML') {
        scrollTop = container.scrollTop() || $(window).scrollTop()
    } else {
        scrollTop = container.scrollTop()
    }
  var offset = container.scrollHeight() - ($(window).height() + scrollTop);
  if(offset <= this.distance) {
    container.trigger("infinite");
  }
}
复制代码

页面js:

$(document.body).infinite().on("infinite", function () {
   // 搞起

})
posted @ 2020-10-13 20:37  戈丫汝  阅读(381)  评论(0编辑  收藏  举报