@@ -247,43 +247,45 @@ proto.initializeGLPlot = function() {
247247 scene . graphDiv . emit ( 'plotly_relayout' , update ) ;
248248 } ;
249249
250- scene . glplot . canvas . addEventListener ( 'mouseup' , function ( ) {
251- relayoutCallback ( scene ) ;
252- } ) ;
250+ if ( scene . glplot . canvas ) {
251+ scene . glplot . canvas . addEventListener ( 'mouseup' , function ( ) {
252+ relayoutCallback ( scene ) ;
253+ } ) ;
254+
255+ scene . glplot . canvas . addEventListener ( 'wheel' , function ( e ) {
256+ if ( gd . _context . _scrollZoom . gl3d ) {
257+ if ( scene . camera . _ortho ) {
258+ var s = ( e . deltaX > e . deltaY ) ? 1.1 : 1.0 / 1.1 ;
259+ var o = scene . glplot . getAspectratio ( ) ;
260+ scene . glplot . setAspectratio ( {
261+ x : s * o . x ,
262+ y : s * o . y ,
263+ z : s * o . z
264+ } ) ;
265+ }
253266
254- scene . glplot . canvas . addEventListener ( 'wheel' , function ( e ) {
255- if ( gd . _context . _scrollZoom . gl3d ) {
256- if ( scene . camera . _ortho ) {
257- var s = ( e . deltaX > e . deltaY ) ? 1.1 : 1.0 / 1.1 ;
258- var o = scene . glplot . getAspectratio ( ) ;
259- scene . glplot . setAspectratio ( {
260- x : s * o . x ,
261- y : s * o . y ,
262- z : s * o . z
263- } ) ;
267+ relayoutCallback ( scene ) ;
264268 }
269+ } , passiveSupported ? { passive : false } : false ) ;
265270
266- relayoutCallback ( scene ) ;
267- }
268- } , passiveSupported ? { passive : false } : false ) ;
271+ scene . glplot . canvas . addEventListener ( 'mousemove' , function ( ) {
272+ if ( scene . fullSceneLayout . dragmode === false ) return ;
273+ if ( scene . camera . mouseListener . buttons === 0 ) return ;
269274
270- scene . glplot . canvas . addEventListener ( 'mousemove' , function ( ) {
271- if ( scene . fullSceneLayout . dragmode === false ) return ;
272- if ( scene . camera . mouseListener . buttons === 0 ) return ;
273-
274- var update = makeUpdate ( ) ;
275- scene . graphDiv . emit ( 'plotly_relayouting' , update ) ;
276- } ) ;
275+ var update = makeUpdate ( ) ;
276+ scene . graphDiv . emit ( 'plotly_relayouting' , update ) ;
277+ } ) ;
277278
278- if ( ! scene . staticMode ) {
279- scene . glplot . canvas . addEventListener ( 'webglcontextlost' , function ( event ) {
280- if ( gd && gd . emit ) {
281- gd . emit ( 'plotly_webglcontextlost' , {
282- event : event ,
283- layer : scene . id
284- } ) ;
285- }
286- } , false ) ;
279+ if ( ! scene . staticMode ) {
280+ scene . glplot . canvas . addEventListener ( 'webglcontextlost' , function ( event ) {
281+ if ( gd && gd . emit ) {
282+ gd . emit ( 'plotly_webglcontextlost' , {
283+ event : event ,
284+ layer : scene . id
285+ } ) ;
286+ }
287+ } , false ) ;
288+ }
287289 }
288290
289291 scene . glplot . oncontextloss = function ( ) {
0 commit comments