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

Commit 29ef510

Browse files
mprokopowiczkara
authored andcommitted
feat(gesture): allow to change maxClickDistance through setMaxClickDistance (#10498)
Fixes #10492
1 parent 241bbc4 commit 29ef510

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/core/services/gesture/gesture.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var HANDLERS = {};
66
* as well as other information abstracted from the DOM.
77
*/
88

9-
var pointer, lastPointer, forceSkipClickHijack = false;
9+
var pointer, lastPointer, forceSkipClickHijack = false, maxClickDistance = 6;
1010

1111
/**
1212
* The position of the most recent click if that click was on a label element.
@@ -21,7 +21,7 @@ angular
2121
.module('material.core.gestures', [ ])
2222
.provider('$mdGesture', MdGestureProvider)
2323
.factory('$$MdGestureHandler', MdGestureHandler)
24-
.run( attachToDocument );
24+
.run(attachToDocument );
2525

2626
/**
2727
* @ngdoc service
@@ -32,6 +32,7 @@ angular
3232
* In some scenarios on Mobile devices (without jQuery), the click events should NOT be hijacked.
3333
* `$mdGestureProvider` is used to configure the Gesture module to ignore or skip click hijacking on mobile
3434
* devices.
35+
* You can also change max click distance (6px by default) if you have issues on some touch screens.
3536
*
3637
* <hljs lang="js">
3738
* app.config(function($mdGestureProvider) {
@@ -40,6 +41,9 @@ angular
4041
* // intercept click events during the capture phase.
4142
* $mdGestureProvider.skipClickHijack();
4243
*
44+
* // If hijcacking clicks, change default 6px click distance
45+
* $mdGestureProvider.setMaxClickDistance(12);
46+
*
4347
* });
4448
* </hljs>
4549
*
@@ -54,6 +58,10 @@ MdGestureProvider.prototype = {
5458
return forceSkipClickHijack = true;
5559
},
5660

61+
setMaxClickDistance: function(clickDistance) {
62+
maxClickDistance = parseInt(clickDistance);
63+
},
64+
5765
/**
5866
* $get is used to build an instance of $mdGesture
5967
* @ngInject
@@ -84,7 +92,6 @@ function MdGesture($$MdGestureHandler, $$rAF, $timeout) {
8492
};
8593

8694
if (self.isHijackingClicks) {
87-
var maxClickDistance = 6;
8895
self.handler('click', {
8996
options: {
9097
maxDistance: maxClickDistance

0 commit comments

Comments
 (0)