@@ -194,24 +194,30 @@ Plotly.plot = function(gd, data, layout, config) {
194
194
}
195
195
}
196
196
197
- if ( fullLayout . _hasCategory ( 'gl' ) && fullLayout . _glcanvas . empty ( ) ) {
198
- fullLayout . _glcanvas . enter ( ) . append ( 'canvas' )
199
- . attr ( 'class' , function ( d ) {
200
- return 'gl-canvas gl-canvas-' + d . key . replace ( 'Layer' , '' ) ;
201
- } )
202
- . style ( 'position' , 'absolute' )
203
- . style ( 'top' , 0 )
204
- . style ( 'left' , 0 )
205
- . style ( 'width' , '100%' )
206
- . style ( 'height' , '100%' )
207
- . style ( 'pointer-events' , 'none' )
208
- . style ( 'overflow' , 'visible' ) ;
209
- }
210
-
211
- fullLayout . _glcanvas
197
+ fullLayout . _glcanvas = fullLayout . _glcontainer . selectAll ( '.gl-canvas' ) . data ( fullLayout . _hasCategory ( 'gl' ) ? [ {
198
+ key : 'contextLayer'
199
+ } , {
200
+ key : 'focusLayer'
201
+ } , {
202
+ key : 'pickLayer'
203
+ } ] : [ ] ) ;
204
+
205
+ fullLayout . _glcanvas . enter ( ) . append ( 'canvas' )
206
+ . attr ( 'class' , function ( d ) {
207
+ return 'gl-canvas gl-canvas-' + d . key . replace ( 'Layer' , '' ) ;
208
+ } )
209
+ . style ( 'position' , 'absolute' )
210
+ . style ( 'top' , 0 )
211
+ . style ( 'left' , 0 )
212
+ . style ( 'width' , '100%' )
213
+ . style ( 'height' , '100%' )
214
+ . style ( 'pointer-events' , 'none' )
215
+ . style ( 'overflow' , 'visible' )
212
216
. attr ( 'width' , fullLayout . width )
213
217
. attr ( 'height' , fullLayout . height ) ;
214
218
219
+ fullLayout . _glcanvas . exit ( ) . remove ( ) ;
220
+
215
221
return Lib . syncOrAsync ( [
216
222
subroutines . layoutStyles
217
223
] , gd ) ;
@@ -3049,15 +3055,7 @@ function makePlotFramework(gd) {
3049
3055
3050
3056
fullLayout . _glcontainer . enter ( ) . append ( 'div' )
3051
3057
. classed ( 'gl-container' , true ) ;
3052
-
3053
- fullLayout . _glcanvas = fullLayout . _glcontainer . selectAll ( '.gl-canvas' )
3054
- . data ( [ {
3055
- key : 'contextLayer'
3056
- } , {
3057
- key : 'focusLayer'
3058
- } , {
3059
- key : 'pickLayer'
3060
- } ] ) ;
3058
+ fullLayout . _glcanvas ;
3061
3059
3062
3060
fullLayout . _paperdiv . selectAll ( '.main-svg' ) . remove ( ) ;
3063
3061
0 commit comments