Description
When scrolling horizontally/vertically sometimes a $scope is created and almost immediately destroyed before the DOM can even render the data generated from that $scope.
This results in a lot of $timeout functions still being ran even after the $scope of the cell/column/row has already been destroyed.
You can see many timeouts happening as you are scrolling through the grid if you use chromes performance tracker. Below is a snippet of all of them happening. Each one takes one average 200ms to complete.
When looking through the un-minified version of ui-grid i found many timeouts that were just set, and forgotten about.
By using $scope.on('$destroy') to cancel any timeouts created, this should improve scroll performance by canceling the timeout before it is ran, instead of wasting performance on executing timeouts on scopes that have already been destroyed.
This is a good article to read about timeouts, and how they should always be canceled in destroy events as to avoid potential problems.
https://www.bennadel.com/blog/2548-don-t-forget-to-cancel-timeout-timers-in-your-destroy-events-in-angularjs.htm