From bba9e795ca7550ade41a322e142e36f55db0538e Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 1 Dec 2014 10:41:39 -0600 Subject: [PATCH] fix(menuClose): expire nextViewOptions --- js/angular/directive/menuClose.js | 3 ++- js/angular/service/history.js | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/js/angular/directive/menuClose.js b/js/angular/directive/menuClose.js index e9b30bdbb8..b1f7d86b7d 100644 --- a/js/angular/directive/menuClose.js +++ b/js/angular/directive/menuClose.js @@ -33,7 +33,8 @@ IonicModule if (sideMenuCtrl) { $ionicHistory.nextViewOptions({ historyRoot: true, - disableAnimate: true + disableAnimate: true, + expire: 300 }); sideMenuCtrl.close(); } diff --git a/js/angular/service/history.js b/js/angular/service/history.js index 025904067b..504db8c8d9 100644 --- a/js/angular/service/history.js +++ b/js/angular/service/history.js @@ -21,9 +21,10 @@ IonicModule '$state', '$location', '$window', + '$timeout', '$ionicViewSwitcher', '$ionicNavViewDelegate', -function($rootScope, $state, $location, $window, $ionicViewSwitcher, $ionicNavViewDelegate) { +function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $ionicNavViewDelegate) { // history actions while navigating views var ACTION_INITIAL_VIEW = 'initialView'; @@ -40,7 +41,7 @@ function($rootScope, $state, $location, $window, $ionicViewSwitcher, $ionicNavVi var DIRECTION_NONE = 'none'; var stateChangeCounter = 0; - var lastStateId, nextViewOptions, forcedNav; + var lastStateId, nextViewOptions, nextViewExpireTimer, forcedNav; var viewHistory = { histories: { root: { historyId: 'root', parentHistoryId: null, stack: [], cursor: -1 } }, @@ -364,6 +365,7 @@ function($rootScope, $state, $location, $window, $ionicViewSwitcher, $ionicNavVi hist.stack.push(viewHistory.views[viewId]); } + $timeout.cancel(nextViewExpireTimer); if (nextViewOptions) { if (nextViewOptions.disableAnimate) direction = DIRECTION_NONE; if (nextViewOptions.disableBack) viewHistory.views[viewId].backViewId = null; @@ -627,11 +629,17 @@ function($rootScope, $state, $location, $window, $ionicViewSwitcher, $ionicNavVi */ nextViewOptions: function(opts) { if (arguments.length) { + $timeout.cancel(nextViewExpireTimer); if (opts === null) { nextViewOptions = opts; } else { nextViewOptions = nextViewOptions || {}; extend(nextViewOptions, opts); + if (nextViewOptions.expire) { + nextViewExpireTimer = $timeout(function(){ + nextViewOptions = null; + }, nextViewOptions.expire); + } } } return nextViewOptions;