我获得了滚动事件的指令,但我只想向下滚动事件。
.directive('whenScrolled', function() {
return function(scope, elm, attr) {
var raw = elm[0];
elm.bind('scroll', function() {
if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
scope.$apply(attr.whenScrolled);
}
});
};
})
答案 0 :(得分:0)
我已通过以下代码解决了这个问题。
//=========================================================================
// Custom Infinite Scoller for table edit
//=========================================================================
.directive('whenScrolled', function() {
return function(scope, elm, attr) {
var raw = elm[0];
̶e̶l̶m̶.̶b̶i̶n̶d̶(̶'̶w̶h̶e̶e̶l̶'̶,̶ ̶f̶u̶n̶c̶t̶i̶o̶n̶(̶)̶ ̶{̶
elm.bind('wheel', function(event) {
var delta;
if (event.wheelDelta){
delta = event.wheelDelta;
}else{
delta = -1 *event.deltaY;
}
if (delta < 0){
//call whenScrolled attribute to HTML for calling function from controller --- Scroll Up
scope.$apply(attr.whenScrolled);
}else if (delta > 0){
//do nothing --- Scroll Down
}
});
};
})