Skip to content

Commit

Permalink
fix(loading): potential race condition with showing and hiding loadin…
Browse files Browse the repository at this point in the history
…g in same watch cycle
  • Loading branch information
perrygovier committed Aug 19, 2014
1 parent 840c014 commit 65aece2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/angular/service/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ function($ionicLoadingConfig, $document, $ionicTemplateLoader, $ionicBackdrop, $
$ionicBackdrop.release();
$ionicBackdrop.getElement().removeClass('backdrop-loading');
}
self.element.removeClass('active');
$document[0].body.classList.remove('loading-active');
// wrapping in a timeout to make process asyncronous
$timeout(function(){
self.element.removeClass('active');
$document[0].body.classList.remove('loading-active');
}, 10);
setTimeout(function() {
!self.isShown && self.element.removeClass('visible');
}, 200);
Expand Down
1 change: 1 addition & 0 deletions test/unit/angular/service/loading.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ describe('$ionicLoading service', function() {
$timeout.flush();
expect(angular.element(document.body).hasClass('loading-active')).toBe(true);
loader.hide();
$timeout.flush();
expect(angular.element(document.body).hasClass('loading-active')).toBe(false);
}));

Expand Down

0 comments on commit 65aece2

Please sign in to comment.