habitica/website/public/js/directives/when-scrolled.directive.js

20 lines
390 B
JavaScript
Raw Normal View History

2015-06-08 08:13:55 +00:00
'use strict';
(function(){
angular
.module('habitrpg')
.directive('whenScrolled', whenScrolled);
2015-06-08 08:13:55 +00:00
function whenScrolled() {
return function($scope, elm, attr) {
var raw = elm[0];
2015-06-08 08:13:55 +00:00
elm.bind('scroll', function() {
if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
$scope.$apply(attr.whenScrolled);
}
});
};
}
}());