Skip to content

Commit 4265bab

Browse files
committed
emit 'plotly_webglcontextlost' for gl3d canvas
1 parent 23647bd commit 4265bab

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/plots/gl3d/scene.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ function render(scene) {
170170
}
171171

172172
function initializeGLPlot(scene, fullLayout, canvas, gl) {
173+
var gd = scene.graphDiv;
174+
173175
var glplotOptions = {
174176
canvas: canvas,
175177
gl: gl,
@@ -220,18 +222,22 @@ function initializeGLPlot(scene, fullLayout, canvas, gl) {
220222

221223
var update = {};
222224
update[scene.id + '.camera'] = getLayoutCamera(scene.camera);
223-
scene.saveCamera(scene.graphDiv.layout);
225+
scene.saveCamera(gd.layout);
224226
scene.graphDiv.emit('plotly_relayout', update);
225227
};
226228

227229
scene.glplot.canvas.addEventListener('mouseup', relayoutCallback.bind(null, scene));
228230
scene.glplot.canvas.addEventListener('wheel', relayoutCallback.bind(null, scene), passiveSupported ? {passive: false} : false);
229231

230232
if(!scene.staticMode) {
231-
scene.glplot.canvas.addEventListener('webglcontextlost', function(ev) {
232-
Lib.warn('Lost WebGL context.');
233-
ev.preventDefault();
234-
});
233+
scene.glplot.canvas.addEventListener('webglcontextlost', function(event) {
234+
if(gd && gd.emit) {
235+
gd.emit('plotly_webglcontextlost', {
236+
event: event,
237+
layer: scene.id
238+
});
239+
}
240+
}, false);
235241
}
236242

237243
if(!scene.camera) {

0 commit comments

Comments
 (0)