Skip to content

Commit b840d52

Browse files
authored
Merge pull request #4546 from plotly/fix-webgl-ipad-pro
Fix 3-D config for webgl buffer on iPad Pro & iPad 7th + iOs v13 + Safari
2 parents e1e12b9 + aa28eba commit b840d52

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"gl-mat4": "^1.2.0",
8383
"gl-mesh3d": "^2.3.0",
8484
"gl-plot2d": "^1.4.3",
85-
"gl-plot3d": "^2.4.1",
85+
"gl-plot3d": "^2.4.2",
8686
"gl-pointcloud2d": "^1.0.2",
8787
"gl-scatter3d": "^1.2.2",
8888
"gl-select-box": "^1.0.3",

src/plots/gl3d/scene.js

+34-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ var createPlot = glPlot3d.createScene;
1515

1616
var getContext = require('webgl-context');
1717
var passiveSupported = require('has-passive-events');
18-
var isMobile = require('is-mobile')({ tablet: true });
1918

2019
var Registry = require('../../registry');
2120
var Lib = require('../../lib');
@@ -31,6 +30,39 @@ var createAxesOptions = require('./layout/convert');
3130
var createSpikeOptions = require('./layout/spikes');
3231
var computeTickMarks = require('./layout/tick_marks');
3332

33+
var isMobile = require('is-mobile');
34+
var tablet = isTablet();
35+
36+
function isTablet() {
37+
if(!navigator) return false;
38+
39+
var ua;
40+
// same interface as applied by is-mobile module
41+
if(!ua && typeof navigator !== 'undefined') ua = navigator.userAgent;
42+
if(ua && ua.headers && typeof ua.headers['user-agent'] === 'string') {
43+
ua = ua.headers['user-agent'];
44+
}
45+
if(typeof ua !== 'string') return false;
46+
47+
var result = isMobile({
48+
ua: ua,
49+
tablet: true
50+
});
51+
52+
// handle iPad pro or iPad with iOs 13 using Safari
53+
// see https://github.com/plotly/plotly.js/issues/4502
54+
if(
55+
result === false &&
56+
ua.indexOf('Macintosh') !== -1 &&
57+
ua.indexOf('Safari') !== -1 &&
58+
navigator.maxTouchPoints > 1
59+
) {
60+
result = true;
61+
}
62+
63+
return result;
64+
}
65+
3466

3567
var STATIC_CANVAS, STATIC_CONTEXT;
3668

@@ -96,7 +128,7 @@ proto.tryCreatePlot = function() {
96128
canvas: scene.canvas,
97129
gl: scene.gl,
98130
glOptions: {
99-
preserveDrawingBuffer: isMobile,
131+
preserveDrawingBuffer: tablet,
100132
premultipliedAlpha: true,
101133
antialias: true
102134
},

0 commit comments

Comments
 (0)