Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngTouch): don't prevent the click event after a touchmove #10985

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/ngTouch/directive/ngClick.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
// double-tapping, and then fire a click event.
//
// This delay sucks and makes mobile apps feel unresponsive.
// So we detect touchstart, touchmove, touchcancel and touchend ourselves and determine when
// So we detect touchstart, touchcancel and touchend ourselves and determine when
// the user has tapped on something.
//
// What happens when the browser then generates a click event?
Expand All @@ -78,7 +78,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
// So the sequence for a tap is:
// - global touchstart: Sets an "allowable region" at the point touched.
// - element's touchstart: Starts a touch
// (- touchmove or touchcancel ends the touch, no click follows)
// (- touchcancel ends the touch, no click follows)
// - element's touchend: Determines if the tap is valid (didn't move too far away, didn't hold
// too long) and fires the user's tap handler. The touchend also calls preventGhostClick().
// - preventGhostClick() removes the allowable region the global touchstart created.
Expand Down Expand Up @@ -227,10 +227,6 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
touchStartY = e.clientY;
});

element.on('touchmove', function(event) {
resetState();
});

element.on('touchcancel', function(event) {
resetState();
});
Expand Down
8 changes: 4 additions & 4 deletions test/ngTouch/directive/ngClickSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('ngClick (touch)', function() {
}));


it('should not click if a touchmove comes before touchend', inject(function($rootScope, $compile, $rootElement) {
it('should not prevent click if a touchmove comes before touchend', inject(function($rootScope, $compile, $rootElement) {
element = $compile('<div ng-click="tapped = true"></div>')($rootScope);
$rootElement.append(element);
$rootScope.$digest();
Expand All @@ -112,11 +112,11 @@ describe('ngClick (touch)', function() {
browserTrigger(element, 'touchmove');
browserTrigger(element, 'touchend',{
keys: [],
x: 400,
y: 400
x: 15,
y: 15
});

expect($rootScope.tapped).toBeUndefined();
expect($rootScope.tapped).toEqual(true);
}));

it('should add the CSS class while the element is held down, and then remove it', inject(function($rootScope, $compile, $rootElement) {
Expand Down