@@ -8,6 +8,7 @@ var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
8
8
var TOUCH_ACTION_NONE = 'none' ;
9
9
var TOUCH_ACTION_PAN_X = 'pan-x' ;
10
10
var TOUCH_ACTION_PAN_Y = 'pan-y' ;
11
+ var TOUCH_ACTION_MAP = getTouchActionProps ( ) ;
11
12
12
13
/**
13
14
* Touch Action
@@ -32,7 +33,7 @@ TouchAction.prototype = {
32
33
value = this . compute ( ) ;
33
34
}
34
35
35
- if ( NATIVE_TOUCH_ACTION && this . manager . element . style ) {
36
+ if ( NATIVE_TOUCH_ACTION && this . manager . element . style && TOUCH_ACTION_MAP [ value ] ) {
36
37
this . manager . element . style [ PREFIXED_TOUCH_ACTION ] = value ;
37
38
}
38
39
this . actions = value . toLowerCase ( ) . trim ( ) ;
@@ -64,11 +65,6 @@ TouchAction.prototype = {
64
65
* @param {Object } input
65
66
*/
66
67
preventDefaults : function ( input ) {
67
- // not needed with native support for the touchAction property
68
- if ( NATIVE_TOUCH_ACTION ) {
69
- return ;
70
- }
71
-
72
68
var srcEvent = input . srcEvent ;
73
69
var direction = input . offsetDirection ;
74
70
@@ -79,9 +75,9 @@ TouchAction.prototype = {
79
75
}
80
76
81
77
var actions = this . actions ;
82
- var hasNone = inStr ( actions , TOUCH_ACTION_NONE ) ;
83
- var hasPanY = inStr ( actions , TOUCH_ACTION_PAN_Y ) ;
84
- var hasPanX = inStr ( actions , TOUCH_ACTION_PAN_X ) ;
78
+ var hasNone = inStr ( actions , TOUCH_ACTION_NONE ) && ! TOUCH_ACTION_MAP [ TOUCH_ACTION_NONE ] ;
79
+ var hasPanY = inStr ( actions , TOUCH_ACTION_PAN_Y ) && ! TOUCH_ACTION_MAP [ TOUCH_ACTION_PAN_Y ] ;
80
+ var hasPanX = inStr ( actions , TOUCH_ACTION_PAN_X ) && ! TOUCH_ACTION_MAP [ TOUCH_ACTION_PAN_X ] ;
85
81
86
82
if ( hasNone ) {
87
83
//do not prevent defaults if this is a tap gesture
@@ -151,3 +147,18 @@ function cleanTouchActions(actions) {
151
147
152
148
return TOUCH_ACTION_AUTO ;
153
149
}
150
+
151
+ function getTouchActionProps ( ) {
152
+ if ( ! NATIVE_TOUCH_ACTION ) {
153
+ return false ;
154
+ }
155
+ var touchMap = { } ;
156
+ var cssSupports = window . CSS && window . CSS . supports ;
157
+ [ 'auto' , 'manipulation' , 'pan-y' , 'pan-x' , 'pan-x pan-y' , 'none' ] . forEach ( function ( val ) {
158
+
159
+ // If css.supports is not supported but there is native touch-action assume it supports
160
+ // all values. This is the case for IE 10 and 11.
161
+ touchMap [ val ] = cssSupports ? window . CSS . supports ( 'touch-action' , val ) : true ;
162
+ } ) ;
163
+ return touchMap ;
164
+ }
0 commit comments