Skip to content

Commit 8915392

Browse files
committed
Make gl-components use pre-created canvases
1 parent dd82961 commit 8915392

File tree

10 files changed

+13
-15
lines changed

10 files changed

+13
-15
lines changed

src/plot_api/plot_api.js

+2
Original file line numberDiff line numberDiff line change
@@ -3056,6 +3056,8 @@ function makePlotFramework(gd) {
30563056
.style('position', 'absolute')
30573057
.style('top', 0)
30583058
.style('left', 0)
3059+
.style('width', '100%')
3060+
.style('height', '100%')
30593061
.style('pointer-events', 'none')
30603062
.style('overflow', 'visible');
30613063

src/plots/gl2d/scene2d.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ proto.makeFramework = function() {
111111
this.gl = STATIC_CONTEXT;
112112
}
113113
else {
114-
var liveCanvas = document.createElement('canvas');
114+
var liveCanvas = this.container.querySelector('.gl-canvas-focus');
115115

116116
var gl = getContext({
117117
canvas: liveCanvas,
@@ -139,7 +139,7 @@ proto.makeFramework = function() {
139139
// disabling user select on the canvas
140140
// sanitizes double-clicks interactions
141141
// ref: https://github.com/plotly/plotly.js/issues/744
142-
canvas.className += 'user-select-none';
142+
canvas.className += ' user-select-none';
143143

144144
// create SVG container for hover text
145145
var svgContainer = this.svgContainer = document.createElementNS(
@@ -158,7 +158,6 @@ proto.makeFramework = function() {
158158

159159
// append canvas, hover svg and mouse div to container
160160
var container = this.container;
161-
container.appendChild(canvas);
162161
container.appendChild(svgContainer);
163162
container.appendChild(mouseContainer);
164163

@@ -369,7 +368,6 @@ proto.destroy = function() {
369368

370369
this.glplot.dispose();
371370

372-
if(!this.staticPlot) this.container.removeChild(this.canvas);
373371
this.container.removeChild(this.svgContainer);
374372
this.container.removeChild(this.mouseContainer);
375373

src/plots/gl3d/scene.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ function render(scene) {
136136

137137
function initializeGLPlot(scene, fullLayout, canvas, gl) {
138138
var glplotOptions = {
139-
canvas: canvas,
140139
gl: gl,
141140
container: scene.container,
141+
canvas: scene.container.querySelector('.gl-canvas-focus'),
142142
axes: scene.axesOptions,
143143
spikes: scene.spikeOptions,
144144
pickRadius: 10,
@@ -228,8 +228,7 @@ function initializeGLPlot(scene, fullLayout, canvas, gl) {
228228
function Scene(options, fullLayout) {
229229

230230
// create sub container for plot
231-
var sceneContainer = document.createElement('div');
232-
var plotContainer = options.container;
231+
var sceneContainer = fullLayout._glcontainer.node();
233232

234233
// keep a ref to the graph div to fire hover+click events
235234
this.graphDiv = options.graphDiv;
@@ -251,7 +250,6 @@ function Scene(options, fullLayout) {
251250
sceneContainer.style.position = 'absolute';
252251
sceneContainer.style.top = sceneContainer.style.left = '0px';
253252
sceneContainer.style.width = sceneContainer.style.height = '100%';
254-
plotContainer.appendChild(sceneContainer);
255253

256254
this.fullLayout = fullLayout;
257255
this.id = options.id || 'scene';

src/traces/contourgl/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ContourGl.plot = require('./convert');
2121
ContourGl.moduleType = 'trace';
2222
ContourGl.name = 'contourgl';
2323
ContourGl.basePlotModule = require('../../plots/gl2d');
24-
ContourGl.categories = ['gl2d', '2dMap'];
24+
ContourGl.categories = ['gl', 'gl2d', '2dMap'];
2525
ContourGl.meta = {
2626
description: [
2727
'WebGL contour (beta)'

src/traces/heatmapgl/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ HeatmapGl.plot = require('./convert');
2121
HeatmapGl.moduleType = 'trace';
2222
HeatmapGl.name = 'heatmapgl';
2323
HeatmapGl.basePlotModule = require('../../plots/gl2d');
24-
HeatmapGl.categories = ['gl2d', '2dMap'];
24+
HeatmapGl.categories = ['gl', 'gl2d', '2dMap'];
2525
HeatmapGl.meta = {
2626
description: [
2727
'WebGL version of the heatmap trace type.'

src/traces/mesh3d/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Mesh3D.plot = require('./convert');
2020
Mesh3D.moduleType = 'trace';
2121
Mesh3D.name = 'mesh3d',
2222
Mesh3D.basePlotModule = require('../../plots/gl3d');
23-
Mesh3D.categories = ['gl3d'];
23+
Mesh3D.categories = ['gl', 'gl3d'];
2424
Mesh3D.meta = {
2525
description: [
2626
'Draws sets of triangles with coordinates given by',

src/traces/pointcloud/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pointcloud.plot = require('./convert');
2020
pointcloud.moduleType = 'trace';
2121
pointcloud.name = 'pointcloud';
2222
pointcloud.basePlotModule = require('../../plots/gl2d');
23-
pointcloud.categories = ['gl2d', 'showLegend'];
23+
pointcloud.categories = ['gl', 'gl2d', 'showLegend'];
2424
pointcloud.meta = {
2525
description: [
2626
'The data visualized as a point cloud set in `x` and `y`',

src/traces/scatter3d/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Scatter3D.calc = require('./calc');
2020
Scatter3D.moduleType = 'trace';
2121
Scatter3D.name = 'scatter3d';
2222
Scatter3D.basePlotModule = require('../../plots/gl3d');
23-
Scatter3D.categories = ['gl3d', 'symbols', 'markerColorscale', 'showLegend'];
23+
Scatter3D.categories = ['gl', 'gl3d', 'symbols', 'markerColorscale', 'showLegend'];
2424
Scatter3D.meta = {
2525
hrName: 'scatter_3d',
2626
description: [

src/traces/scattergl/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ScatterGl.selectPoints = require('./select');
2323
ScatterGl.moduleType = 'trace';
2424
ScatterGl.name = 'scattergl';
2525
ScatterGl.basePlotModule = require('../../plots/gl2d');
26-
ScatterGl.categories = ['gl2d', 'symbols', 'errorBarsOK', 'markerColorscale', 'showLegend', 'scatter-like'];
26+
ScatterGl.categories = ['gl', 'gl2d', 'symbols', 'errorBarsOK', 'markerColorscale', 'showLegend', 'scatter-like'];
2727
ScatterGl.meta = {
2828
description: [
2929
'The data visualized as scatter point or lines is set in `x` and `y`',

src/traces/surface/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Surface.plot = require('./convert');
2020
Surface.moduleType = 'trace';
2121
Surface.name = 'surface';
2222
Surface.basePlotModule = require('../../plots/gl3d');
23-
Surface.categories = ['gl3d', '2dMap', 'noOpacity'];
23+
Surface.categories = ['gl', 'gl3d', '2dMap', 'noOpacity'];
2424
Surface.meta = {
2525
description: [
2626
'The data the describes the coordinates of the surface is set in `z`.',

0 commit comments

Comments
 (0)