From 5c3500743c38ffd80583b7fb749f6300380e5e7f Mon Sep 17 00:00:00 2001 From: Andy Joslin Date: Wed, 30 Apr 2014 13:27:39 -0600 Subject: [PATCH] refactor($ionicModal): backdrop click-close only after animating in --- js/angular/directive/modal.js | 4 ++-- js/angular/service/modal.js | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/js/angular/directive/modal.js b/js/angular/directive/modal.js index b8de1864d2..5915f69201 100644 --- a/js/angular/directive/modal.js +++ b/js/angular/directive/modal.js @@ -8,8 +8,8 @@ IonicModule restrict: 'E', transclude: true, replace: true, - template: '' }; }]); diff --git a/js/angular/service/modal.js b/js/angular/service/modal.js index 9d8c7e99e7..400a4dea64 100644 --- a/js/angular/service/modal.js +++ b/js/angular/service/modal.js @@ -118,7 +118,14 @@ function($rootScope, $document, $compile, $timeout, $ionicPlatform, $ionicTempla self.el.classList.add('active'); }, 20); - return $timeout(angular.noop, 400); + return $timeout(function() { + //After animating in, allow hide on backdrop click + angular.element(self.el).on('click', function(e) { + if (e.target === self.el) { + self.hide(); + } + }); + }, 400); }, /** @@ -139,6 +146,7 @@ function($rootScope, $document, $compile, $timeout, $ionicPlatform, $ionicTempla .removeClass('ng-enter ng-enter-active active'); }, 20); + angular.element(self.el).off('click'); self._isShown = false; self.scope.$parent && self.scope.$parent.$broadcast('modal.hidden', self); self._deregisterBackButton && self._deregisterBackButton();