angular-endless-scroll
angular-endless-scroll copied to clipboard
Adding additional DOM elements and scrolling within $digest cycle
I had to modify the _onScroll function to include if (this.scope.$$phase), this allows scrolling from within another digest cycle. I was getting a $digest already in progress error. Any thoughts?
`EndlessScroller.prototype._onScroll = function () { * if (this.scope.$$phase) { // Define a throttled check method, if it's not already defined if (!this._throttledCheck) { this._throttledCheck = throttle(angular.bind(this, this.check), this.options.scrollThrottle); } // Check if there's a need to fetch more data this._throttledCheck(); } else {*
this.scope.$apply(angular.bind(this, function() {
// Define a throttled check method, if it's not already defined
if (!this._throttledCheck) {
this._throttledCheck = throttle(angular.bind(this, this.check), this.options.scrollThrottle);
}
// Check if there's a need to fetch more data
this._throttledCheck();
}));
}
};`