Skip to content

Commit 876117e

Browse files
authored
Update utils.js
1 parent 18d8496 commit 876117e

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

utils.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,25 @@ function showMessage(message, duration) {
145145

146146
// device and platform queries
147147

148-
const isMobile = navigator.userAgent.match('Mobile') ?? false;
149-
const isSafari = isMobile && navigator.userAgent.toLowerCase().indexOf('safari') != -1;
148+
let isMobile = false;
150149

151-
const isMac = navigator.platform.indexOf('Mac') > -1;
152-
const isWindows = navigator.platform.indexOf('Win') > -1;
150+
if (navigator.userAgentData
151+
&& navigator.userAgentData.mobile) isMobile = true;
152+
153+
if (navigator.userAgent
154+
&& navigator.userAgent.includes('Mobile')) isMobile = true;
155+
156+
let isSafari = false;
157+
158+
if (navigator.userAgentData
159+
&& navigator.userAgentData.platform === 'iOS') isSafari = true;
160+
161+
if (navigator.userAgent
162+
&& isMobile
163+
&& navigator.userAgent.toLowerCase().includes('safari')) isSafari = true;
164+
165+
const isMac = navigator.platform.includes('Mac');
166+
const isWindows = navigator.platform.includes('Win');
153167

154168
let isLandscape = window.matchMedia('(orientation: landscape)').matches;
155169

0 commit comments

Comments
 (0)