fix(menuClose): expire nextViewOptions

This commit is contained in:
Adam Bradley
2014-12-01 10:41:39 -06:00
parent e74de97ce2
commit bba9e795ca
2 changed files with 12 additions and 3 deletions

View File

@@ -33,7 +33,8 @@ IonicModule
if (sideMenuCtrl) {
$ionicHistory.nextViewOptions({
historyRoot: true,
disableAnimate: true
disableAnimate: true,
expire: 300
});
sideMenuCtrl.close();
}

View File

@@ -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;