I am currently developing a directive that requires three specific values:
- scrollTop
- offsetHeight
scrollHeight
projectModule.directive('scroller', function ($window) { return { restrict: 'A', link: function (scope, elem, attrs) { var rawElement = angular.element($window); angular.element($window).bind('scroll', function () { var scrollTop = rawElement.scrollTop(); var offsetHeight = rawElement.offsetHeight; var scrollHeight = rawElement.scrollHeight; console.log(scrollTop + " ," + offsetHeight + " ," + scrollHeight); scope.$apply(); }); }; });
While I can easily retrieve the scrollTop value using rawElement.scrollTop() function, I'm unsure how to obtain the offsetHeight and scrollHeight of that particular element.
I aim to implement this logic-
if ((rawElement.scrollTop + rawElement.offsetHeight + 5) >= rawElement.scrollHeight) {
scope.$apply(); //For infinite scrolling
}
Thank you in advance.