UNPKG

qcobjects

Version:

QCObjects is an Open-source framework that empowers full-stack developers to make micro-services and micro-frontends into an N-Tier architecture.

29 lines (26 loc) 853 B
import { logger } from "./Logger"; import { isBrowser } from "./platform"; export let supportsPassive = false; export const captureFalseTouch = ():boolean | { passive: boolean; } => { return (supportsPassive) ? ({ passive: true }) : (false); }; // Test via a getter in the options object to see if the passive property is accessed if (isBrowser) { try { const opts = Object.defineProperty({}, "passive", { get() { supportsPassive = true; return supportsPassive; } }); (window as any).addEventListener("testPassive", null, opts); (window as any).removeEventListener("testPassive", null, opts); } catch (e:any) { logger.debug(`An error ocurred: ${e}.`); supportsPassive = false; } } else { supportsPassive = false; }