Skip to content

Commit

Permalink
fix: remove $timeout in faScrollView and use scope.$$postDigest instead
Browse files Browse the repository at this point in the history
With a large collection, this is much faster than lots of $timeout calls.
  • Loading branch information
RobinBressan committed Jul 7, 2014
1 parent b4477a2 commit 137f260
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 37 deletions.
17 changes: 5 additions & 12 deletions dist/famous-angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -3366,7 +3366,7 @@ angular.module('famous.angular')
*/

angular.module('famous.angular')
.directive('faScrollView', ['$famous', '$famousDecorator', '$timeout', function ($famous, $famousDecorator, $timeout) {
.directive('faScrollView', ['$famous', '$famousDecorator', function ($famous, $famousDecorator) {
return {
template: '<div></div>',
restrict: 'E',
Expand All @@ -3387,14 +3387,8 @@ angular.module('famous.angular')
isolate.renderNode = new ScrollView(options);

var updateScrollview = function(init){
//$timeout hack used here because the
//updateScrollview function will get called
//before the $index values get re-bound
//through ng-repeat. The result is that
//the items get sorted here, then the indexes
//get re-bound, and thus the results are incorrectly
//ordered.
$timeout(function(){
// Synchronize the update on the next digest cycle
scope.$$postDigest(function(){
_children.sort(function(a, b){
return a.index - b.index;
});
Expand All @@ -3415,9 +3409,8 @@ angular.module('famous.angular')

var viewSeq = new ViewSequence(options);
isolate.renderNode.sequenceFrom(viewSeq);

})
}
});
};

$famousDecorator.sequenceWith(
scope,
Expand Down
Loading

0 comments on commit 137f260

Please sign in to comment.