device.js 677 B

123456789101112131415
  1. const UA = navigator.userAgent;
  2. const testElement = document.createElement( 'div' );
  3. export const isMobile = /(iphone|ipod|ipad|android)/gi.test( UA ) ||
  4. ( navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1 ); // iPadOS
  5. export const isChrome = /chrome/i.test( UA ) && !/edge/i.test( UA );
  6. export const isAndroid = /android/gi.test( UA );
  7. // Flags if we should use zoom instead of transform to scale
  8. // up slides. Zoom produces crisper results but has a lot of
  9. // xbrowser quirks so we only use it in whitelisted browsers.
  10. export const supportsZoom = 'zoom' in testElement.style && !isMobile &&
  11. ( isChrome || /Version\/[\d\.]+.*Safari/.test( UA ) );