Skip to content

Commit 66fe64b

Browse files
author
Sebastien Pereira
committed
rename feature detection properties
1 parent 74652f7 commit 66fe64b

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

events.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ define([
2424
if (this._targetElement) {
2525
return;// already initialized
2626
}
27-
if (!has("pointer")) {
28-
if (has("mspointer")) {
27+
if (!has("pointer-events")) {
28+
if (has("mspointer-events")) {
2929
mspointer.registerHandlers(targetElement);
3030
} else {
31-
if (has("touch")) {
32-
if (!has("mobile")) {
31+
if (has("touch-events")) {
32+
if (!has("touch-device")) {
3333
mouse.registerHandlers(targetElement);
3434
if (has("chrome")) {
3535
touch.registerHandlers(targetElement);
@@ -83,10 +83,10 @@ define([
8383
if (!this._targetElement) {
8484
return false;// not initialized
8585
}
86-
if (has("pointer")) {
86+
if (has("pointer-events")) {
8787
return targetElement.setPointerCapture(pointerId);// use native Pointer Events method
8888
} else {
89-
if (has("mspointer")) {
89+
if (has("mspointer-events")) {
9090
return targetElement.msSetPointerCapture(pointerId);// use native Pointer Events method
9191
} else {
9292
if (pointerId === 1) { // mouse always gets ID = 1
@@ -108,10 +108,10 @@ define([
108108
if (!this._targetElement) {
109109
return false;
110110
}
111-
if (has("pointer")) {
111+
if (has("pointer-events")) {
112112
return targetElement.releasePointerCapture(pointerId);
113113
} else {
114-
if (has("mspointer")) {
114+
if (has("mspointer-events")) {
115115
return targetElement.msReleasePointerCapture(pointerId);
116116
} else {
117117
if (pointerId === 1) {
@@ -141,21 +141,21 @@ define([
141141
}
142142

143143
// CSS rule when user agent implements W3C Pointer Events or when a polyfill is in place.
144-
if (has("pointer")) {
144+
if (has("pointer-events")) {
145145
insertTouchActionCSSRule("touch-action");
146146
}
147147

148148
// CSS rule for IE10 and IE11 preview
149-
if (has("mspointer")) {
149+
if (has("mspointer-events")) {
150150
insertTouchActionCSSRule("-ms-touch-action");
151151
}
152152
// CSS rule to map CSS attribute in case user agent has native support for touch-action or -ms-touch-action
153153
// CSS property.
154-
if (has("touchAction")) {
154+
if (has("css-touch-action")) {
155155
insertTouchActionCSSRule("touch-action");
156156
} else {
157157
// CSS rule for IE10 and IE11 preview
158-
if (has("msTouchAction")) {
158+
if (has("css-ms-touch-action")) {
159159
insertTouchActionCSSRule("-ms-touch-action");
160160
}
161161
}
@@ -180,7 +180,7 @@ define([
180180
* @param e click event
181181
*/
182182
function clickHandler(e) {
183-
if (has("touch")) {
183+
if (has("touch-events")) {
184184
// (7) Android 4.1.1 generates a click after touchend even when touchstart is prevented.
185185
// if we receive a native click at an element with touch action disabled we just have to absorb it.
186186
// (fixed in Android 4.1.2+)

handlers/features.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
define([
55
"requirejs-dplugins/has"
66
], function (has) {
7-
has.add("touch", "ontouchstart" in document); // UA supports Touch Events
8-
has.add("pointer", "onpointerdown" in document); // UA supports Pointer Events
9-
has.add("mspointer", "onmspointerdown" in document); // UA supports Pointer Events (IE10+IE11 preview)
7+
has.add("touch-events", "ontouchstart" in document); // UA supports Touch Events
8+
has.add("pointer-events", "onpointerdown" in document); // UA supports Pointer Events
9+
has.add("mspointer-events", "onmspointerdown" in document); // UA supports Pointer Events (IE10+IE11 preview)
1010
has.add("chrome", /chrome/i.test(navigator.userAgent)); // UA is chrome.
11-
has.add("mobile", /(mobile)|(android)/i.test(navigator.userAgent)); // mobile device
12-
has.add("touchAction", "touchAction" in document.body.style);// touch-action CSS
13-
has.add("msTouchAction", "msTouchAction" in document.body.style);// -ms-touch-action CSS
11+
has.add("touch-device", /(mobile)|(android)/i.test(navigator.userAgent)); // mobile device
12+
has.add("css-touch-action", "touchAction" in document.body.style);// touch-action CSS
13+
has.add("css-ms-touch-action", "msTouchAction" in document.body.style);// -ms-touch-action CSS
1414
return has;
1515
});

handlers/touch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ define([
131131
tracker.update(touch, e, touchTarget);
132132
// touch default actions must be prevented.
133133
// Let user agent handle it if it supports the touch-action CSS property.
134-
if (!has("touchAction")) {
134+
if (!has("css-touch-action")) {
135135
e.preventDefault();
136136
}
137137
}

0 commit comments

Comments
 (0)