我在 mCustomScrollBar onToTalScroll 上附加内容时遇到错误。我想在到达结束滚动时加载内容。
Controller
$scope.initialize = function(){
$('#sent').mCustomScrollbar({
scrollInertia: 350,
callbacks:{
onTotalScroll:function(){
$scope.showMore();
}
}
});
};
我遇到错误“无法读取未定义的属性'childNodes'”
最佳答案
app.directive("whenScrolled", function(){
return{
restrict: 'A',
link: function(scope, elem, attrs){
// we get a list of elements of size 1 and need the first element
raw = elem[0];
// we load more elements when scrolled past a limit
elem.bind("scroll", function(){
if(raw.scrollTop+raw.offsetHeight+5 >= raw.scrollHeight){
scope.loading = true;
// we can give any function which loads more elements into the list
scope.$apply(attrs.whenScrolled);
}
});
}
}
});
关于javascript - 当用户使用 mCustomScrollbar onTotalScroll 到达结束滚动时,如何加载内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46678052/