forked from Modernizr/Modernizr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
touch.js
29 lines (25 loc) · 973 Bytes
/
touch.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
//
// The Modernizr.touch test only indicates if the browser supports
// touch events, which does not necessarily reflect a touchscreen
// device, as evidenced by tablets running Windows 7 or, alas,
// the Palm Pre / WebOS (touch) phones.
//
// Additionally, Chrome (desktop) used to lie about its support on this,
// but that has since been rectified: crbug.com/36415
//
// We also test for Firefox 4 Multitouch Support.
//
// For more info, see: modernizr.github.com/Modernizr/touch.html
//
Modernizr.addTest('touch', function() {
var bool;
if(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
bool = true;
} else {
var query = ['@media (',Modernizr._prefixes.join('touch-enabled),('),'heartz',')','{#modernizr{top:9px;position:absolute}}'].join('');
Modernizr.testStyles(query, function( node ) {
bool = node.offsetTop === 9;
});
}
return bool;
});