mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
sideMenu menuNav directive to stop next view animation and close side-menu
This commit is contained in:
20
js/ext/angular/src/directive/ionicSideMenu.js
vendored
20
js/ext/angular/src/directive/ionicSideMenu.js
vendored
@@ -299,5 +299,23 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture', 'ionic.service.vie
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
.directive('menuNav', ['$ionicViewService', function($ionicViewService) {
|
||||
return {
|
||||
restrict: 'AC',
|
||||
require: '^ionSideMenus',
|
||||
link: function($scope, $element, $attr, sideMenuCtrl) {
|
||||
$element.bind('click', function(){
|
||||
$ionicViewService.nextViewOptions({
|
||||
disableAnimate: true,
|
||||
disableBack: true
|
||||
});
|
||||
sideMenuCtrl.close();
|
||||
});
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
})();
|
||||
|
||||
17
js/ext/angular/src/service/ionicView.js
vendored
17
js/ext/angular/src/service/ionicView.js
vendored
@@ -124,6 +124,7 @@ angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform'])
|
||||
currentView = viewHistory.currentView,
|
||||
backView = viewHistory.backView,
|
||||
forwardView = viewHistory.forwardView,
|
||||
nextViewOptions = this.nextViewOptions(),
|
||||
rsp = {
|
||||
viewId: null,
|
||||
navAction: null,
|
||||
@@ -159,7 +160,7 @@ angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform'])
|
||||
rsp.navAction = 'moveBack';
|
||||
rsp.viewId = backView.viewId;
|
||||
//when going back, erase scrollValues
|
||||
currentView.rememberedScrollValues = {};
|
||||
currentView.rememberedScrollValues = {};
|
||||
if(backView.historyId === currentView.historyId) {
|
||||
// went back in the same history
|
||||
rsp.navDirection = 'back';
|
||||
@@ -240,6 +241,12 @@ angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform'])
|
||||
hist.stack.push(viewHistory.views[rsp.viewId]);
|
||||
}
|
||||
|
||||
if(nextViewOptions) {
|
||||
if(nextViewOptions.disableAnimate) rsp.navDirection = null;
|
||||
if(nextViewOptions.disableBack) viewHistory.views[rsp.viewId].backViewId = null;
|
||||
this.nextViewOptions(null);
|
||||
}
|
||||
|
||||
this.setNavViews(rsp.viewId);
|
||||
|
||||
hist.cursor = viewHistory.currentView.index;
|
||||
@@ -389,6 +396,14 @@ angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform'])
|
||||
return { historyId: 'root', scope: $rootScope };
|
||||
},
|
||||
|
||||
nextViewOptions: function(opts) {
|
||||
if(arguments.length) {
|
||||
this._nextOpts = opts;
|
||||
} else {
|
||||
return this._nextOpts;
|
||||
}
|
||||
},
|
||||
|
||||
getRenderer: function(navViewElement, navViewAttrs, navViewScope) {
|
||||
var service = this;
|
||||
var registerData;
|
||||
|
||||
Reference in New Issue
Block a user