aboutsummaryrefslogtreecommitdiff
path: root/js/utils/device.js
blob: 1e787fb58c9cf86a2d42c76db9c2f6c7a82c780b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const UA = navigator.userAgent;
const testElement = document.createElement( 'div' );

export const isMobile = /(iphone|ipod|ipad|android)/gi.test( UA ) ||
						( navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1 ); // iPadOS

export const isChrome = /chrome/i.test( UA ) && !/edge/i.test( UA );

export const isAndroid = /android/gi.test( UA );

// Flags if we should use zoom instead of transform to scale
// up slides. Zoom produces crisper results but has a lot of
// xbrowser quirks so we only use it in whitelisted browsers.
export const supportsZoom = 'zoom' in testElement.style && !isMobile &&
				( isChrome || /Version\/[\d\.]+.*Safari/.test( UA ) );

export const supportsHistoryAPI = typeof window.history.replaceState === 'function' && !/PhantomJS/.test( UA );