Skip to content

Commit 436fca4

Browse files
committed
add extra logic to get userAgent
1 parent 63c51d1 commit 436fca4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/plots/gl3d/scene.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,25 @@ var isMobile = require('is-mobile');
3434
var tablet = isTablet();
3535

3636
function isTablet() {
37-
var navigator = window.navigator;
38-
var userAgent = navigator.userAgent;
37+
var ua;
38+
// same interface as applied by is-mobile module
39+
if(!ua && typeof navigator !== 'undefined') ua = navigator.userAgent;
40+
if(ua && ua.headers && typeof ua.headers['user-agent'] === 'string') {
41+
ua = ua.headers['user-agent'];
42+
}
43+
if(typeof ua !== 'string') return false;
3944

4045
var result = isMobile({
41-
ua: userAgent,
46+
ua: ua,
4247
tablet: true
4348
});
4449

4550
// handle iPad pro or iPad with iOs 13 using Safari
4651
// see https://github.com/plotly/plotly.js/issues/4502
4752
if(
4853
result === false &&
49-
userAgent.indexOf('Macintosh') !== -1 &&
50-
userAgent.indexOf('Safari') !== -1 &&
54+
ua.indexOf('Macintosh') !== -1 &&
55+
ua.indexOf('Safari') !== -1 &&
5156
navigator.maxTouchPoints > 1
5257
) {
5358
result = true;

0 commit comments

Comments
 (0)