From 4ac3dfea080354c8a1a5352aeda8d7610f4af930 Mon Sep 17 00:00:00 2001 From: Marco Del Toro Date: Fri, 15 Nov 2019 15:49:21 -0600 Subject: [PATCH 1/2] Add detection to for iPadOS in IS_IPAD const --- src/js/utils/browser.js | 79 +++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/src/js/utils/browser.js b/src/js/utils/browser.js index bccc034cab..ca03cc6ff1 100644 --- a/src/js/utils/browser.js +++ b/src/js/utils/browser.js @@ -9,27 +9,6 @@ const USER_AGENT = window.navigator && window.navigator.userAgent || ''; const webkitVersionMap = (/AppleWebKit\/([\d.]+)/i).exec(USER_AGENT); const appleWebkitVersion = webkitVersionMap ? parseFloat(webkitVersionMap.pop()) : null; -/** - * Whether or not this device is an iPad. - * - * @static - * @const - * @type {Boolean} - */ -export const IS_IPAD = (/iPad/i).test(USER_AGENT); - -/** - * Whether or not this device is an iPhone. - * - * @static - * @const - * @type {Boolean} - */ -// The Facebook app's UIWebView identifies as both an iPhone and iPad, so -// to identify iPhones, we need to exclude iPads. -// http://artsy.github.io/blog/2012/10/18/the-perils-of-ios-user-agent-sniffing/ -export const IS_IPHONE = (/iPhone/i).test(USER_AGENT) && !IS_IPAD; - /** * Whether or not this device is an iPod. * @@ -39,15 +18,6 @@ export const IS_IPHONE = (/iPhone/i).test(USER_AGENT) && !IS_IPAD; */ export const IS_IPOD = (/iPod/i).test(USER_AGENT); -/** - * Whether or not this is an iOS device. - * - * @static - * @const - * @type {Boolean} - */ -export const IS_IOS = IS_IPHONE || IS_IPAD || IS_IPOD; - /** * The detected iOS version - or `null`. * @@ -183,15 +153,6 @@ export const IE_VERSION = (function() { */ export const IS_SAFARI = (/Safari/i).test(USER_AGENT) && !IS_CHROME && !IS_ANDROID && !IS_EDGE; -/** - * Whether or not this is any flavor of Safari - including iOS. - * - * @static - * @const - * @type {Boolean} - */ -export const IS_ANY_SAFARI = (IS_SAFARI || IS_IOS) && !IS_CHROME; - /** * Whether or not this is a Windows machine. * @@ -212,3 +173,43 @@ export const TOUCH_ENABLED = Dom.isReal() && ( 'ontouchstart' in window || window.navigator.maxTouchPoints || window.DocumentTouch && window.document instanceof window.DocumentTouch); + +/** + * Whether or not this device is an iPad. + * + * @static + * @const + * @type {Boolean} + */ +export const IS_IPAD = (/iPad/i).test(USER_AGENT) || +(IS_SAFARI && TOUCH_ENABLED); + +/** + * Whether or not this device is an iPhone. + * + * @static + * @const + * @type {Boolean} + */ +// The Facebook app's UIWebView identifies as both an iPhone and iPad, so +// to identify iPhones, we need to exclude iPads. +// http://artsy.github.io/blog/2012/10/18/the-perils-of-ios-user-agent-sniffing/ +export const IS_IPHONE = (/iPhone/i).test(USER_AGENT) && !IS_IPAD; + +/** + * Whether or not this is an iOS device. + * + * @static + * @const + * @type {Boolean} + */ +export const IS_IOS = IS_IPHONE || IS_IPAD || IS_IPOD; + +/** + * Whether or not this is any flavor of Safari - including iOS. + * + * @static + * @const + * @type {Boolean} + */ +export const IS_ANY_SAFARI = (IS_SAFARI || IS_IOS) && !IS_CHROME; From 42adf24214a308649ded2bf8d68aa2f8271d143f Mon Sep 17 00:00:00 2001 From: Marco Del Toro Date: Fri, 15 Nov 2019 16:13:17 -0600 Subject: [PATCH 2/2] IS_IPAD in single line --- src/js/utils/browser.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/js/utils/browser.js b/src/js/utils/browser.js index ca03cc6ff1..34daf646c2 100644 --- a/src/js/utils/browser.js +++ b/src/js/utils/browser.js @@ -181,8 +181,7 @@ export const TOUCH_ENABLED = Dom.isReal() && ( * @const * @type {Boolean} */ -export const IS_IPAD = (/iPad/i).test(USER_AGENT) || -(IS_SAFARI && TOUCH_ENABLED); +export const IS_IPAD = (/iPad/i).test(USER_AGENT) || (IS_SAFARI && TOUCH_ENABLED); /** * Whether or not this device is an iPhone.