Skip to content

Fix 3-D config for webgl buffer on iPad Pro & iPad 7th + iOs v13 + Safari #4546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"gl-mat4": "^1.2.0",
"gl-mesh3d": "^2.3.0",
"gl-plot2d": "^1.4.3",
"gl-plot3d": "^2.4.1",
"gl-plot3d": "^2.4.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"gl-pointcloud2d": "^1.0.2",
"gl-scatter3d": "^1.2.2",
"gl-select-box": "^1.0.3",
Expand Down
36 changes: 34 additions & 2 deletions src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var createPlot = glPlot3d.createScene;

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

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

var isMobile = require('is-mobile');
var tablet = isTablet();

function isTablet() {
if(!navigator) return false;

var ua;
// same interface as applied by is-mobile module
if(!ua && typeof navigator !== 'undefined') ua = navigator.userAgent;
if(ua && ua.headers && typeof ua.headers['user-agent'] === 'string') {
ua = ua.headers['user-agent'];
}
if(typeof ua !== 'string') return false;

var result = isMobile({
ua: ua,
tablet: true
});

// handle iPad pro or iPad with iOs 13 using Safari
// see https://github.com/plotly/plotly.js/issues/4502
if(
result === false &&
ua.indexOf('Macintosh') !== -1 &&
ua.indexOf('Safari') !== -1 &&
navigator.maxTouchPoints > 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you find this solution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

) {
result = true;
}

return result;
}


var STATIC_CANVAS, STATIC_CONTEXT;

Expand Down Expand Up @@ -96,7 +128,7 @@ proto.tryCreatePlot = function() {
canvas: scene.canvas,
gl: scene.gl,
glOptions: {
preserveDrawingBuffer: isMobile,
preserveDrawingBuffer: tablet,
premultipliedAlpha: true,
antialias: true
},
Expand Down