maplair
Version:
JavaScript library for mobile-friendly interactive maps
31 lines (30 loc) • 1.45 kB
JavaScript
//#region src/core/Browser.js
const chrome = userAgentContains("chrome");
const safari = !chrome && userAgentContains("safari");
const mobile = typeof orientation !== "undefined";
const reducedMotion = navigator.preferences?.reducedMotion?.value ? navigator.preferences.reducedMotion.value === "reduce" : typeof window === "undefined" ? true : window?.matchMedia("(prefers-reduced-motion: reduce)").matches;
const pointer = typeof window === "undefined" ? false : !!window.PointerEvent;
const touchNative = typeof window === "undefined" ? false : "ontouchstart" in window || !!window.TouchEvent;
const touch = touchNative || pointer;
const retina = typeof window === "undefined" || typeof window.devicePixelRatio === "undefined" ? false : window.devicePixelRatio > 1;
const mac = typeof navigator === "undefined" || typeof navigator.platform === "undefined" ? false : navigator.platform.startsWith("Mac");
const linux = typeof navigator === "undefined" || typeof navigator.platform === "undefined" ? false : navigator.platform.startsWith("Linux");
function userAgentContains(str) {
if (typeof navigator === "undefined" || typeof navigator.userAgent === "undefined") return false;
return navigator.userAgent.toLowerCase().includes(str);
}
var Browser_default = {
chrome,
safari,
mobile,
reducedMotion,
pointer,
touch,
touchNative,
retina,
mac,
linux
};
//#endregion
export { Browser_default as default };
//# sourceMappingURL=Browser.js.map