mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(menuClose): do not show next back button
When navigating to a view from a button/link with the `menuClose` attribute directive, the back button should not show for the next view.
This commit is contained in:
1
js/angular/directive/menuClose.js
vendored
1
js/angular/directive/menuClose.js
vendored
@@ -28,6 +28,7 @@ IonicModule
|
||||
// lower priority than navAnimation which allows navTransition
|
||||
// to override this directive's nextTransition() call
|
||||
$ionicViewSwitcher.nextTransition('none');
|
||||
$ionicViewSwitcher.nextShowBack(false);
|
||||
sideMenuCtrl.close();
|
||||
}
|
||||
});
|
||||
|
||||
12
js/angular/service/viewSwitcher.js
vendored
12
js/angular/service/viewSwitcher.js
vendored
@@ -29,8 +29,7 @@ function($timeout, $compile, $controller, $document, $ionicClickBlock, $ionicCon
|
||||
var VIEW_STATUS_STAGED = 'stage';
|
||||
|
||||
var transitionCounter = 0;
|
||||
var nextTransition;
|
||||
var nextDirection;
|
||||
var nextTransition, nextDirection, nextShowBack;
|
||||
ionic.transition = ionic.transition || {};
|
||||
ionic.transition.isActive = false;
|
||||
var isActiveTimer;
|
||||
@@ -74,6 +73,7 @@ function($timeout, $compile, $controller, $document, $ionicClickBlock, $ionicCon
|
||||
var transition = nextTransition || ionic.DomUtil.cachedAttr(enteringEle, 'view-transition') || state.viewTransition || $ionicConfig.views.transition() || 'none';
|
||||
direction = nextDirection || ionic.DomUtil.cachedAttr(enteringEle, 'view-direction') || state.viewDirection || direction || 'none';
|
||||
var shouldAnimate = (transition !== 'none' && direction !== 'none');
|
||||
showBack = (nextShowBack === true || nextShowBack === false ? nextShowBack : !!showBack);
|
||||
|
||||
return {
|
||||
transition: transition,
|
||||
@@ -83,7 +83,7 @@ function($timeout, $compile, $controller, $document, $ionicClickBlock, $ionicCon
|
||||
stateId: enteringView.stateId,
|
||||
stateName: enteringView.stateName,
|
||||
stateParams: enteringView.stateParams,
|
||||
showBack: !!showBack
|
||||
showBack: showBack
|
||||
};
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ function($timeout, $compile, $controller, $document, $ionicClickBlock, $ionicCon
|
||||
}
|
||||
|
||||
// remove any references that could cause memory issues
|
||||
nextTransition = nextDirection = enteringView = enteringEle = leavingEle = null;
|
||||
nextTransition = nextDirection = nextShowBack = enteringView = enteringEle = leavingEle = null;
|
||||
}
|
||||
|
||||
},
|
||||
@@ -383,6 +383,10 @@ function($timeout, $compile, $controller, $document, $ionicClickBlock, $ionicCon
|
||||
nextDirection = val;
|
||||
},
|
||||
|
||||
nextShowBack: function(val) {
|
||||
nextShowBack = val;
|
||||
},
|
||||
|
||||
getTransitionData: getTransitionData,
|
||||
|
||||
viewEleIsActive: function(viewEle, isActiveAttr) {
|
||||
|
||||
@@ -79,6 +79,47 @@ describe('Ionic View Switcher', function() {
|
||||
expect(d.direction).toEqual('forward');
|
||||
}));
|
||||
|
||||
it('should set showBack when the view data sets it', inject(function($ionicViewSwitcher) {
|
||||
var d = $ionicViewSwitcher.getTransitionData(null, null, null, null, true);
|
||||
expect(d.showBack).toEqual(true);
|
||||
|
||||
d = $ionicViewSwitcher.getTransitionData(null, null, null, null, false);
|
||||
expect(d.showBack).toEqual(false);
|
||||
|
||||
d = $ionicViewSwitcher.getTransitionData(null, null, null, null, null);
|
||||
expect(d.showBack).toEqual(false);
|
||||
}));
|
||||
|
||||
it('should override showBack from view data w/ $ionicViewSwitcher.nextShowBack() setting', inject(function($ionicViewSwitcher) {
|
||||
$ionicViewSwitcher.nextShowBack(true);
|
||||
var d = $ionicViewSwitcher.getTransitionData(null, null, null, null, true);
|
||||
expect(d.showBack).toEqual(true);
|
||||
|
||||
$ionicViewSwitcher.nextShowBack(false);
|
||||
var d = $ionicViewSwitcher.getTransitionData(null, null, null, null, true);
|
||||
expect(d.showBack).toEqual(false);
|
||||
|
||||
$ionicViewSwitcher.nextShowBack(true);
|
||||
d = $ionicViewSwitcher.getTransitionData(null, null, null, null, false);
|
||||
expect(d.showBack).toEqual(true);
|
||||
|
||||
$ionicViewSwitcher.nextShowBack(false);
|
||||
d = $ionicViewSwitcher.getTransitionData(null, null, null, null, false);
|
||||
expect(d.showBack).toEqual(false);
|
||||
|
||||
$ionicViewSwitcher.nextShowBack(true);
|
||||
d = $ionicViewSwitcher.getTransitionData(null, null, null, null, null);
|
||||
expect(d.showBack).toEqual(true);
|
||||
|
||||
$ionicViewSwitcher.nextShowBack(false);
|
||||
d = $ionicViewSwitcher.getTransitionData(null, null, null, null, null);
|
||||
expect(d.showBack).toEqual(false);
|
||||
|
||||
$ionicViewSwitcher.nextShowBack(null);
|
||||
d = $ionicViewSwitcher.getTransitionData(null, null, null, null, true);
|
||||
expect(d.showBack).toEqual(true);
|
||||
}));
|
||||
|
||||
it('should get an empty entering element with an empty navViewElement', inject(function($ionicViewSwitcher) {
|
||||
var navViewElement = angular.element('<div class="view-container">');
|
||||
var switcher = $ionicViewSwitcher.create(null, navViewElement, {}, {});
|
||||
|
||||
Reference in New Issue
Block a user