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

Commit 17f09dc

Browse files
mohammadrafighkara
authored andcommitted
fix(gestures): fix the swipe and scrolling issues on touch devices (#10455)
Fixes #10187, #10145
1 parent 71cd3e9 commit 17f09dc

File tree

6 files changed

+15
-36
lines changed

6 files changed

+15
-36
lines changed

src/components/swipe/swipe.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,8 @@ function getDirective(name) {
8282

8383
/* @ngInject */
8484
function DirectiveFactory($parse) {
85-
return {restrict: 'A', link: postLink};
86-
87-
function postLink(scope, element, attr) {
88-
element.css('touch-action', attr['mdSwipeTouchAction'] || 'none');
89-
85+
return { restrict: 'A', link: postLink };
86+
function postLink(scope, element, attr) {
9087
var fn = $parse(attr[directiveName]);
9188
element.on(eventName, function(ev) {
9289
scope.$applyAsync(function() { fn(scope, { $event: ev }); });

src/components/swipe/swipe.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[md-swipe-left], [md-swipe-right] {
2+
touch-action : pan-y;
3+
}
4+
5+
[md-swipe-up], [md-swipe-down] {
6+
touch-action : pan-x;
7+
}

src/components/swipe/swipe.spec.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/components/tabs/js/tabsDirective.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function MdTabs ($$mdSvgRegistry) {
159159
'\'md-disabled\': tab.scope.disabled ' +
160160
'}" ' +
161161
'ng-disabled="tab.scope.disabled" ' +
162-
'md-swipe-left="$mdTabsCtrl.nextPage()" md-swipe-touch-action="pan-y" ' +
162+
'md-swipe-left="$mdTabsCtrl.nextPage()" ' +
163163
'md-swipe-right="$mdTabsCtrl.previousPage()" ' +
164164
'md-tabs-template="::tab.label" ' +
165165
'md-scope="::tab.parent"></md-tab-item> ' +
@@ -183,7 +183,6 @@ function MdTabs ($$mdSvgRegistry) {
183183
'aria-labelledby="tab-item-{{::tab.id}}" ' +
184184
'md-swipe-left="$mdTabsCtrl.swipeContent && $mdTabsCtrl.incrementIndex(1)" ' +
185185
'md-swipe-right="$mdTabsCtrl.swipeContent && $mdTabsCtrl.incrementIndex(-1)" ' +
186-
'md-swipe-touch-action="pan-y" ' +
187186
'ng-if="tab.hasContent" ' +
188187
'ng-repeat="(index, tab) in $mdTabsCtrl.tabs" ' +
189188
'ng-class="{ ' +

src/core/services/gesture/gesture.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,9 @@ function attachToDocument( $mdGesture, $$MdGestureHandler ) {
652652
updatePointerState(ev, pointer);
653653
pointer.endTime = +Date.now();
654654

655-
runHandlers('end', ev);
655+
if (ev.type !== 'pointercancel') {
656+
runHandlers('end', ev);
657+
}
656658

657659
lastPointer = pointer;
658660
pointer = null;

src/core/services/gesture/gesture.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('$mdGesture', function() {
8383
expect(endSpy1).toHaveBeenCalled();
8484
}));
8585

86-
it('gesture{down,move,up,cancel}', inject(function($document) {
86+
it('gesture{down,move,up}', inject(function($document) {
8787
$document.triggerHandler({
8888
type: 'pointerdown',
8989
target: childEl[0]
@@ -106,7 +106,7 @@ describe('$mdGesture', function() {
106106
$document.triggerHandler('pointermove');
107107
expect(moveSpy1).toHaveBeenCalled();
108108
$document.triggerHandler('pointercancel');
109-
expect(endSpy1).toHaveBeenCalled();
109+
expect(endSpy1).not.toHaveBeenCalled();
110110
}));
111111

112112
it('mouse{down,move,up,leave}', inject(function($document) {

0 commit comments

Comments
 (0)