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

View File

@ -70,7 +70,7 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture'])
sideMenuCtrl._handleDrag(e);
};
Gesture.on('drag', dragFn, $element);
var dragGesture = Gesture.on('drag', dragFn, $element);
var dragReleaseFn = function(e) {
if(!defaultPrevented) {
@ -79,7 +79,7 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture'])
defaultPrevented = false;
};
Gesture.on('release', dragReleaseFn, $element);
var releaseGesture = Gesture.on('release', dragReleaseFn, $element);
sideMenuCtrl.setContent({
onDrag: function(e) {},
@ -105,8 +105,8 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture'])
// Cleanup
$scope.$on('$destroy', function() {
Gesture.off('drag', dragFn);
Gesture.off('release', dragReleaseFn);
Gesture.off(dragGesture, 'drag', dragFn);
Gesture.off(releaseGesture, 'release', dragReleaseFn);
});
};
}

View File

@ -66,15 +66,15 @@
if(ele.control) {
return inputTapPolyfill(ele.control, e);
}
} else if( ele.tagName === "A" ) {
var href = ele.getAttribute('href');
if(href) {
ele.click();
e.stopPropagation();
e.preventDefault();
return false;
}
}
/* Let ng-click handle this
else if( ele.tagName === "A" || ele.tagName === "BUTTON" ) {
ele.click();
e.stopPropagation();
e.preventDefault();
return false;
}
*/
ele = ele.parentElement;
}