mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(backbutton): Allow only one back button listener to run per click, closes #693
This commit is contained in:
22
js/ext/angular/src/service/ionicModal.js
vendored
22
js/ext/angular/src/service/ionicModal.js
vendored
@@ -26,25 +26,13 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv
|
||||
|
||||
$timeout(function(){
|
||||
element.addClass('ng-enter-active');
|
||||
|
||||
if(!self.didInitEvents) {
|
||||
var onHardwareBackButton = function() {
|
||||
self.hide();
|
||||
};
|
||||
|
||||
self.scope.$on('$destroy', function() {
|
||||
$ionicPlatform.offHardwareBackButton(onHardwareBackButton);
|
||||
});
|
||||
|
||||
// Support Android back button to close
|
||||
$ionicPlatform.onHardwareBackButton(onHardwareBackButton);
|
||||
|
||||
self.didInitEvents = true;
|
||||
}
|
||||
|
||||
self.scope.$parent.$broadcast('modal.shown');
|
||||
}, 20);
|
||||
|
||||
self._deregisterBackButton = $ionicPlatform.registerBackButtonAction(function(){
|
||||
self.hide();
|
||||
}, 200);
|
||||
|
||||
},
|
||||
// Hide the modal
|
||||
hide: function() {
|
||||
@@ -65,6 +53,8 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv
|
||||
ionic.views.Modal.prototype.hide.call(this);
|
||||
|
||||
this.scope.$parent.$broadcast('modal.hidden');
|
||||
|
||||
this._deregisterBackButton && this._deregisterBackButton();
|
||||
},
|
||||
|
||||
// Remove and destroy the modal scope
|
||||
|
||||
Reference in New Issue
Block a user