[IMP] web: add the detection of iPadOS

Before this commit, the iPad with iPadOS was not detected as
'isMobileDevice'.

Now the detection is more accurate.
This commit is contained in:
Romeo Fragomeli
2021-05-05 10:20:06 +00:00
parent e7d6a68a56
commit c1c225eff2
+6 -7
View File
@@ -14,6 +14,11 @@ const bus = new Bus();
* this file someday.
*/
const maxTouchPoints = navigator.maxTouchPoints || 1;
const isAndroid = /Android/i.test(navigator.userAgent);
const isIOS = /(iPad|iPhone|iPod)/i.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && maxTouchPoints > 1);
const isOtherMobileDevice = /(webOS|BlackBerry|Windows Phone)/i.test(navigator.userAgent);
var config = {
device: {
/**
@@ -52,13 +57,7 @@ var config = {
*
* @return {boolean}
*/
isMobileDevice: navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/webOS/i) ||
navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/iPod/i) ||
navigator.userAgent.match(/BlackBerry/i) ||
navigator.userAgent.match(/Windows Phone/i),
isMobileDevice: isAndroid || isIOS || isOtherMobileDevice,
/**
* Mapping between the numbers 0,1,2,3,4,5,6 and some descriptions
*/