Fixed <a href> tap performance using polyfill

This commit is contained in:
Max Lynch
2013-11-19 19:43:12 -06:00
parent 08fd6f864e
commit 04c4900c93
5 changed files with 34 additions and 34 deletions

View File

@@ -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);
});
}