-
Notifications
You must be signed in to change notification settings - Fork 9
/
pointer-prefix.js
57 lines (56 loc) · 1.87 KB
/
pointer-prefix.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* As of 2013-04-11 there is only currently one pointerevent
* implementation (Microsoft in Windows 8); it uses prefixed
* mixed-cap for event names and prefixes its JavaScript
* properties. To simplify development of the W3C tests,
* this file abstracts names of the events and properties.
*/
pointerPrefix = (function() {
// Use maxTouchPoints as our feature detect; this will
// probably need tweaking with new implementations.
if ( "maxTouchPoints" in window.navigator ) {
return {
vendorPrefixing: "",
pointerdown: "pointerdown",
pointerup: "pointerup",
pointercancel: "pointercancel",
pointermove: "pointermove",
pointerover: "pointerover",
pointerout: "pointerout",
pointerenter: "pointerenter",
pointerleave: "pointerleave",
gotpointercapture: "gotpointercapture",
lostpointercapture: "lostpointercapture",
maxTouchPoints: "maxTouchPoints",
pointerType: { "mouse": "mouse", "touch": "touch", "stylus": "stylus" },
touchAction: "touchAction",
PointerEvent: PointerEvent,
setPointerCapture: "setPointerCapture",
releasePointerCapture: "releasePointerCapture"
};
}
else if ( "msMaxTouchPoints" in window.navigator ) {
return {
vendorPrefixing: "MSPointer",
pointerdown: "MSPointerDown",
pointerup: "MSPointerUp",
pointercancel: "MSPointerCancel",
pointermove: "MSPointerMove",
pointerover: "MSPointerOver",
pointerout: "MSPointerOut",
pointerenter: "MSPointerEnter",
pointerleave: "MSPointerLeave",
gotpointercapture: "MSGotPointerCapture",
lostpointercapture: "MSLostPointerCapture",
maxTouchPoints: "msMaxTouchPoints",
pointerType: { "mouse": 4, "touch": 2, "stylus": 99 },
touchAction: "msTouchAction",
PointerEvent: MSPointerEvent,
setPointerCapture: "msSetPointerCapture",
releasePointerCapture: "msReleasePointerCapture"
};
}
else {
//TODO: Assert no pointer events?
}
}());