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

@ -25296,7 +25296,7 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges
var actualLocation = null; var actualLocation = null;
angular.module('ionic.ui.navRouter', []) angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
.run(['$rootScope', function($rootScope) { .run(['$rootScope', function($rootScope) {
$rootScope.stackCursorPosition = 0; $rootScope.stackCursorPosition = 0;
@ -25620,22 +25620,22 @@ angular.module('ionic.ui.navRouter', [])
} }
}]) }])
.directive('navBack', ['$window', '$rootScope', function($window, $rootScope) { .directive('navBack', ['$window', '$rootScope', 'Gesture', function($window, $rootScope, Gesture) {
return { return {
restrict: 'AC', restrict: 'AC',
require: '^?navRouter', require: '^?navRouter',
link: function($scope, $element, $attr, navCtrl) { link: function($scope, $element, $attr, navCtrl) {
var goBack = function() { var goBack = function(e) {
// Only trigger back if the stack is greater than zero // Only trigger back if the stack is greater than zero
if($rootScope.stackCursorPosition > 0) { if($rootScope.stackCursorPosition > 0) {
$window.history.back(); $window.history.back();
} }
}; };
$element.bind('tap', goBack); var tapGesture = Gesture.on('tap', goBack, $element);
$element.bind('click', goBack); $element.bind('click', goBack);
$scope.$on('$destroy', function() { $scope.$on('$destroy', function() {
$element.unbind('tap', goBack); Gesture.off(tapGesture, 'tap', goBack);
$element.unbind('click', goBack); $element.unbind('click', goBack);
}); });
} }
@ -25782,7 +25782,7 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture'])
sideMenuCtrl._handleDrag(e); sideMenuCtrl._handleDrag(e);
}; };
Gesture.on('drag', dragFn, $element); var dragGesture = Gesture.on('drag', dragFn, $element);
var dragReleaseFn = function(e) { var dragReleaseFn = function(e) {
if(!defaultPrevented) { if(!defaultPrevented) {
@ -25791,7 +25791,7 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture'])
defaultPrevented = false; defaultPrevented = false;
}; };
Gesture.on('release', dragReleaseFn, $element); var releaseGesture = Gesture.on('release', dragReleaseFn, $element);
sideMenuCtrl.setContent({ sideMenuCtrl.setContent({
onDrag: function(e) {}, onDrag: function(e) {},
@ -25817,8 +25817,8 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture'])
// Cleanup // Cleanup
$scope.$on('$destroy', function() { $scope.$on('$destroy', function() {
Gesture.off('drag', dragFn); Gesture.off(dragGesture, 'drag', dragFn);
Gesture.off('release', dragReleaseFn); Gesture.off(releaseGesture, 'release', dragReleaseFn);
}); });
}; };
} }

8
dist/js/ionic.js vendored
View File

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

View File

@ -19,7 +19,7 @@
var actualLocation = null; var actualLocation = null;
angular.module('ionic.ui.navRouter', []) angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
.run(['$rootScope', function($rootScope) { .run(['$rootScope', function($rootScope) {
$rootScope.stackCursorPosition = 0; $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 { return {
restrict: 'AC', restrict: 'AC',
require: '^?navRouter', require: '^?navRouter',
link: function($scope, $element, $attr, navCtrl) { link: function($scope, $element, $attr, navCtrl) {
var goBack = function() { var goBack = function(e) {
// Only trigger back if the stack is greater than zero // Only trigger back if the stack is greater than zero
if($rootScope.stackCursorPosition > 0) { if($rootScope.stackCursorPosition > 0) {
$window.history.back(); $window.history.back();
} }
}; };
$element.bind('tap', goBack); var tapGesture = Gesture.on('tap', goBack, $element);
$element.bind('click', goBack); $element.bind('click', goBack);
$scope.$on('$destroy', function() { $scope.$on('$destroy', function() {
$element.unbind('tap', goBack); Gesture.off(tapGesture, 'tap', goBack);
$element.unbind('click', goBack); $element.unbind('click', goBack);
}); });
} }

View File

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

View File

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