mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
refactor: Use stateChange hook for releasing keybinding
This commit is contained in:
@@ -264,10 +264,18 @@ habitrpg.controller("InventoryCtrl",
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$on("habit:keydown", function (e, keyEvent) {
|
||||
if (keyEvent.keyCode == "27") {
|
||||
var listenForEscape = function (event) {
|
||||
if (event.keyCode === 27) {
|
||||
$scope.deselectItem();
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', listenForEscape);
|
||||
|
||||
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams, options){
|
||||
if (toState.name.indexOf('options.inventory') < 0) {
|
||||
document.removeEventListener('keydown', listenForEscape);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.deselectItem = function() {
|
||||
|
||||
Reference in New Issue
Block a user