mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(sideMenu): enable menu w/ different historyId back view
This commit is contained in:
7
js/angular/controller/sideMenuController.js
vendored
7
js/angular/controller/sideMenuController.js
vendored
@@ -368,7 +368,12 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io
|
||||
startX <= self.edgeThreshold ||
|
||||
startX >= self.content.element.offsetWidth - self.edgeThreshold;
|
||||
|
||||
var menuEnabled = self.enableMenuWithBackViews() ? true : !$ionicHistory.backView();
|
||||
var backView = $ionicHistory.backView();
|
||||
var menuEnabled = enableMenuWithBackViews ? true : !backView;
|
||||
if (!menuEnabled) {
|
||||
var currentView = $ionicHistory.currentView() || {};
|
||||
return backView.historyId !== currentView.historyId;
|
||||
}
|
||||
|
||||
return ($scope.dragContent || self.isOpen()) &&
|
||||
dragIsWithinBounds &&
|
||||
|
||||
14
js/angular/service/history.js
vendored
14
js/angular/service/history.js
vendored
@@ -482,9 +482,12 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
|
||||
* @description Returns the view that was before the current view in the history stack.
|
||||
* If the user navigated from View A to View B, then View A would be the back view, and
|
||||
* View B would be the current view.
|
||||
* @returns {string} Returns the back view.
|
||||
* @returns {object} Returns the back view.
|
||||
*/
|
||||
backView: function() {
|
||||
backView: function(view) {
|
||||
if (arguments.length) {
|
||||
viewHistory.backView = view;
|
||||
}
|
||||
return viewHistory.backView;
|
||||
},
|
||||
|
||||
@@ -507,9 +510,12 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
|
||||
* A forward view would exist if the user navigated from View A to View B, then
|
||||
* navigated back to View A. At this point then View B would be the forward view, and View
|
||||
* A would be the current view.
|
||||
* @returns {string} Returns the back view.
|
||||
* @returns {object} Returns the forward view.
|
||||
*/
|
||||
forwardView: function() {
|
||||
forwardView: function(view) {
|
||||
if (arguments.length) {
|
||||
viewHistory.forwardView = view;
|
||||
}
|
||||
return viewHistory.forwardView;
|
||||
},
|
||||
|
||||
|
||||
@@ -170,6 +170,55 @@ describe('Ionic Angular Side Menu', function() {
|
||||
expect(ctrl.isDraggableTarget(e)).toBe(true);
|
||||
|
||||
}));
|
||||
|
||||
it('should isDraggableTarget w/ enableMenuWithBackViews', inject(function($compile, $rootScope, $ionicHistory) {
|
||||
var el = $compile('<ion-side-menus><ion-side-menu-content></ion-side-menu-content></ion-side-menus>')($rootScope.$new());
|
||||
$rootScope.$apply();
|
||||
|
||||
var ctrl = el.controller('ionSideMenus');
|
||||
|
||||
var e = {
|
||||
gesture: {
|
||||
srcEvent: {
|
||||
defaultPrevented: false
|
||||
}
|
||||
},
|
||||
target: {
|
||||
tagName: 'DIV',
|
||||
dataset: {
|
||||
preventScroll: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ctrl.enableMenuWithBackViews(true);
|
||||
expect(ctrl.isDraggableTarget(e)).toBe(true);
|
||||
|
||||
ctrl.enableMenuWithBackViews(false);
|
||||
expect(ctrl.isDraggableTarget(e)).toBe(true);
|
||||
|
||||
ctrl.enableMenuWithBackViews(false);
|
||||
$ionicHistory.currentView({historyId: 'root'});
|
||||
$ionicHistory.backView({historyId: 'root'});
|
||||
expect(ctrl.isDraggableTarget(e)).toBe(false);
|
||||
|
||||
ctrl.enableMenuWithBackViews(false);
|
||||
$ionicHistory.currentView({historyId: 'root'});
|
||||
$ionicHistory.backView(null);
|
||||
expect(ctrl.isDraggableTarget(e)).toBe(true);
|
||||
|
||||
ctrl.enableMenuWithBackViews(true);
|
||||
$ionicHistory.currentView({historyId: 'root'});
|
||||
$ionicHistory.backView({historyId: 'root'});
|
||||
expect(ctrl.isDraggableTarget(e)).toBe(true);
|
||||
|
||||
ctrl.enableMenuWithBackViews(false);
|
||||
$ionicHistory.currentView({historyId: '003'});
|
||||
$ionicHistory.backView({historyId: 'root'});
|
||||
expect(ctrl.isDraggableTarget(e)).toBe(true);
|
||||
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
describe('Ionic Side Menu Content Directive', function () {
|
||||
|
||||
Reference in New Issue
Block a user