UNPKG

1.25 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.getSupport = getSupport;
5
6var _ssrWindow = require("ssr-window");
7
8var support;
9
10function calcSupport() {
11 var window = (0, _ssrWindow.getWindow)();
12 var document = (0, _ssrWindow.getDocument)();
13 return {
14 touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch),
15 pointerEvents: !!window.PointerEvent && 'maxTouchPoints' in window.navigator && window.navigator.maxTouchPoints >= 0,
16 observer: function checkObserver() {
17 return 'MutationObserver' in window || 'WebkitMutationObserver' in window;
18 }(),
19 passiveListener: function checkPassiveListener() {
20 var supportsPassive = false;
21
22 try {
23 var opts = Object.defineProperty({}, 'passive', {
24 // eslint-disable-next-line
25 get: function get() {
26 supportsPassive = true;
27 }
28 });
29 window.addEventListener('testPassiveListener', null, opts);
30 } catch (e) {// No support
31 }
32
33 return supportsPassive;
34 }(),
35 gestures: function checkGestures() {
36 return 'ongesturestart' in window;
37 }()
38 };
39}
40
41function getSupport() {
42 if (!support) {
43 support = calcSupport();
44 }
45
46 return support;
47}
\No newline at end of file