I code an infinite scrolled DIV for an AngularJS bootstrap app, as shown in the following example.
angular.module('scroll', []).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);
}
});
};
});
Data is loaded but the scroll of the DIV goes to bottom and to see the data loaded you need to scroll up again. How do I fix this?