下拉加载
first method:
// 滚动到页面底部加载数据
$scope.page_init = function() {
$(window).scroll(function() {
var bot = 50
if ((bot + $(window).scrollTop()) >= ($(document).height() - $(window).height())&&$scope.res_params.weike.data_num==$scope.res_params.weike.limit) {
if (!$scope.is_loading && !$scope.no_data) {
$scope.res_params.weike.page++
$scope.res_params.weike.data_num=0
$scope.get_res_list($scope.res_params.weike)
}
}
})
}
second method:
$scope.page_init = function() {
$("#live_details").scroll(function () {
var topic_wrap = $('#mianCourse');
var win_h = $(window).height();
var scroll_top = $(this).scrollTop();
if ((topic_wrap.height() - win_h - scroll_top < 50)) {
if(!$scope.is_loading && !$scope.no_data){
$scope.res_params.weike.page++;
$scope.get_res_list($scope.res_params.weike);
}
}
});
}
notice:
- $(“#live_details”) 父级div 的浮动: overflow:auto;
- $(‘#mianCourse’);子级的高度不能写死,否则没法把父级撑开
- 比如bottom:1.5rem,是不对的