首页 > 代码库 > 手机页面滑动加载数据

手机页面滑动加载数据

var $doc, $win, bind;
$doc = $(document);

$win = $(window);

bind = function() {
return $(‘.js-scroll-load‘).each(function() {
var $self, scroll, top;
$self = $(this);
$self.removeClass(‘js-scroll-load‘);
top = $self.offset().top - 300;
$win.on(‘scroll‘, scroll = function() {
if ($doc.scrollTop() + $win.height() > top) {
$self.click();
return $win.off(‘scroll‘, scroll);
}
});
return scroll();
});
};

$(bind);

手机页面滑动加载数据