当前位置 : 主页 > 网页制作 > JQuery >

Jquery WEUI 滚动加载(infinite)不触发

来源:互联网 收集:自由互联 发布时间:2021-06-15
源代码:(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(

源代码:(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 () {
   // 搞起

})
网友评论