mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(swipe): iOS swipe to go back
This commit is contained in:
54
js/angular/controller/navBarController.js
vendored
54
js/angular/controller/navBarController.js
vendored
@@ -239,6 +239,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
|
||||
self.transition(enteringHeaderBar, leavingHeaderBar, viewData);
|
||||
|
||||
self.isInitialized = true;
|
||||
navSwipeAttr('');
|
||||
};
|
||||
|
||||
|
||||
@@ -254,17 +255,39 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
|
||||
ionic.DomUtil.cachedAttr($element, 'nav-bar-transition', viewData.navBarTransition);
|
||||
ionic.DomUtil.cachedAttr($element, 'nav-bar-direction', viewData.direction);
|
||||
|
||||
if (navBarTransition.shouldAnimate) {
|
||||
if (navBarTransition.shouldAnimate && viewData.renderEnd) {
|
||||
navBarAttr(enteringHeaderBar, 'stage');
|
||||
} else {
|
||||
navBarAttr(enteringHeaderBar, 'entering');
|
||||
navBarAttr(leavingHeaderBar, 'leaving');
|
||||
}
|
||||
|
||||
enteringHeaderBarCtrl.resetBackButton();
|
||||
enteringHeaderBarCtrl.resetBackButton(viewData);
|
||||
|
||||
navBarTransition.run(0);
|
||||
|
||||
self.activeTransition = {
|
||||
run: function(step) {
|
||||
navBarTransition.shouldAnimate = false;
|
||||
navBarTransition.direction = 'back';
|
||||
navBarTransition.run(step);
|
||||
},
|
||||
cancel: function(shouldAnimate, speed) {
|
||||
navSwipeAttr(speed);
|
||||
navBarAttr(leavingHeaderBar, 'active');
|
||||
navBarAttr(enteringHeaderBar, 'cached');
|
||||
navBarTransition.shouldAnimate = shouldAnimate;
|
||||
navBarTransition.run(0);
|
||||
self.activeTransition = navBarTransition = null;
|
||||
},
|
||||
complete: function(shouldAnimate, speed) {
|
||||
navSwipeAttr(speed);
|
||||
navBarTransition.shouldAnimate = shouldAnimate;
|
||||
navBarTransition.run(1);
|
||||
queuedTransitionEnd = transitionEnd;
|
||||
}
|
||||
};
|
||||
|
||||
$timeout(enteringHeaderBarCtrl.align, 16);
|
||||
|
||||
queuedTransitionStart = function() {
|
||||
@@ -277,23 +300,26 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
|
||||
|
||||
queuedTransitionEnd = function() {
|
||||
if (latestTransitionId == transitionId || !navBarTransition.shouldAnimate) {
|
||||
for (var x = 0; x < headerBars.length; x++) {
|
||||
headerBars[x].isActive = false;
|
||||
}
|
||||
enteringHeaderBar.isActive = true;
|
||||
|
||||
navBarAttr(enteringHeaderBar, 'active');
|
||||
navBarAttr(leavingHeaderBar, 'cached');
|
||||
|
||||
queuedTransitionEnd = null;
|
||||
transitionEnd();
|
||||
}
|
||||
};
|
||||
|
||||
queuedTransitionStart = null;
|
||||
};
|
||||
|
||||
queuedTransitionStart();
|
||||
function transitionEnd() {
|
||||
for (var x = 0; x < headerBars.length; x++) {
|
||||
headerBars[x].isActive = false;
|
||||
}
|
||||
enteringHeaderBar.isActive = true;
|
||||
|
||||
navBarAttr(enteringHeaderBar, 'active');
|
||||
navBarAttr(leavingHeaderBar, 'cached');
|
||||
|
||||
self.activeTransition = navBarTransition = queuedTransitionEnd = null;
|
||||
}
|
||||
|
||||
queuedTransitionStart();
|
||||
};
|
||||
|
||||
|
||||
@@ -437,6 +463,10 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
|
||||
ctrl && ionic.DomUtil.cachedAttr(ctrl.containerEle(), 'nav-bar', val);
|
||||
}
|
||||
|
||||
function navSwipeAttr(val) {
|
||||
ionic.DomUtil.cachedAttr($element, 'nav-swipe', val);
|
||||
}
|
||||
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
$scope.$parent.$hasHeader = false;
|
||||
|
||||
Reference in New Issue
Block a user