UNPKG

framework7

Version:

Full featured mobile HTML framework for building iOS & Android apps

35 lines 1.06 kB
import { getWindow, getDocument } from 'ssr-window'; let support; function calcSupport() { const window = getWindow(); const document = getDocument(); return { touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch), pointerEvents: !!window.PointerEvent && 'maxTouchPoints' in window.navigator && window.navigator.maxTouchPoints >= 0, passiveListener: function checkPassiveListener() { let supportsPassive = false; try { const opts = Object.defineProperty({}, 'passive', { // eslint-disable-next-line get() { supportsPassive = true; } }); window.addEventListener('testPassiveListener', null, opts); } catch (e) { // No support } return supportsPassive; }(), intersectionObserver: function checkObserver() { return 'IntersectionObserver' in window; }() }; } function getSupport() { if (!support) { support = calcSupport(); } return support; } export { getSupport };