mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Fixed <a href> tap performance using polyfill
This commit is contained in:
10
js/ext/angular/src/directive/ionicNavRouter.js
vendored
10
js/ext/angular/src/directive/ionicNavRouter.js
vendored
@@ -19,7 +19,7 @@
|
||||
|
||||
var actualLocation = null;
|
||||
|
||||
angular.module('ionic.ui.navRouter', [])
|
||||
angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
|
||||
|
||||
.run(['$rootScope', function($rootScope) {
|
||||
$rootScope.stackCursorPosition = 0;
|
||||
@@ -343,22 +343,22 @@ angular.module('ionic.ui.navRouter', [])
|
||||
}
|
||||
}])
|
||||
|
||||
.directive('navBack', ['$window', '$rootScope', function($window, $rootScope) {
|
||||
.directive('navBack', ['$window', '$rootScope', 'Gesture', function($window, $rootScope, Gesture) {
|
||||
return {
|
||||
restrict: 'AC',
|
||||
require: '^?navRouter',
|
||||
link: function($scope, $element, $attr, navCtrl) {
|
||||
var goBack = function() {
|
||||
var goBack = function(e) {
|
||||
// Only trigger back if the stack is greater than zero
|
||||
if($rootScope.stackCursorPosition > 0) {
|
||||
$window.history.back();
|
||||
}
|
||||
};
|
||||
$element.bind('tap', goBack);
|
||||
var tapGesture = Gesture.on('tap', goBack, $element);
|
||||
$element.bind('click', goBack);
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
$element.unbind('tap', goBack);
|
||||
Gesture.off(tapGesture, 'tap', goBack);
|
||||
$element.unbind('click', goBack);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user