Description
Hi
Currently my app experiences big performance issues when scrolling through the list of items.
Having done some investigation I found out that each scroll event causes 2 digest cycles!!!
Taking into account that each digest cycle runs a lot of watchers (~1000) we are getting an unresponsive app.
It's a very bad idea by itself to do anything on every scroll event, even John Resig long time ago warned against using it http://ejohn.org/blog/learning-from-twitter/
But I wonder why do we need to run digest cycles at all when scrolling?
BTW, I found the way to get rid at list of one redundant digest call.
Look at this function
resizeAndScrollHandler = function() {
if (!$rootScope.$$phase && !adapter.isLoading) {
adjustBuffer();
return $scope.$apply();
}
};
$scope.$apply();
call here is redundant because adjustBuffer()
calls $timeout
function, which in its turn calls $scope.$apply();
. So we can get rid of $scope.$apply()
in the code above.