UNPKG

1.02 kBJavaScriptView Raw
1import { getWindow, getDocument } from 'ssr-window';
2let support;
3
4function calcSupport() {
5 const window = getWindow();
6 const document = getDocument();
7 return {
8 smoothScroll: document.documentElement && 'scrollBehavior' in document.documentElement.style,
9 touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch),
10 passiveListener: function checkPassiveListener() {
11 let supportsPassive = false;
12
13 try {
14 const opts = Object.defineProperty({}, 'passive', {
15 // eslint-disable-next-line
16 get() {
17 supportsPassive = true;
18 }
19
20 });
21 window.addEventListener('testPassiveListener', null, opts);
22 } catch (e) {// No support
23 }
24
25 return supportsPassive;
26 }(),
27 gestures: function checkGestures() {
28 return 'ongesturestart' in window;
29 }()
30 };
31}
32
33function getSupport() {
34 if (!support) {
35 support = calcSupport();
36 }
37
38 return support;
39}
40
41export { getSupport };
\No newline at end of file