Skip to content

Commit

Permalink
fix(modal): Don't show click-block-div unnecessarily on remove()
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMa committed Apr 14, 2016
1 parent 72a50b3 commit b0c89ef
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions js/angular/service/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,24 @@ function($rootScope, $ionicBody, $compile, $timeout, $ionicPlatform, $ionicTempl
* @returns {promise} A promise which is resolved when the modal is finished animating out.
*/
remove: function() {
var self = this;
var self = this,
deferred, promise;
self.scope.$parent && self.scope.$parent.$broadcast(self.viewType + '.removed', self);

return self.hide().then(function() {
// Only hide modal, when it is actually shown!
// The hide function shows a click-block-div for a split second, because on iOS,
// clicks will sometimes bleed through/ghost click on underlying elements.
// However, this will make the app unresponsive for short amount of time.
// We don't want that, if the modal window is already hidden.
if (self._isShown) {
promise = self.hide();
} else {
deferred = $$q.defer();
deferred.resolve();
promise = deferred.promise;
}

return promise.then(function() {
self.scope.$destroy();
self.$el.remove();
});
Expand Down

0 comments on commit b0c89ef

Please sign in to comment.