@@ -67,6 +67,11 @@ function Scene2D(options, fullLayout) {
6767 // last pick result
6868 this . pickResult = null ;
6969
70+ // is the mouse over the plot?
71+ // it's OK if this says true when it's not, so long as
72+ // when we get a mouseout we set it to false before handling
73+ this . isMouseOver = true ;
74+
7075 this . bounds = [ Infinity , Infinity , - Infinity , - Infinity ] ;
7176
7277 // flag to stop render loop
@@ -153,6 +158,15 @@ proto.makeFramework = function() {
153158 container . appendChild ( canvas ) ;
154159 container . appendChild ( svgContainer ) ;
155160 container . appendChild ( mouseContainer ) ;
161+
162+ var self = this ;
163+ mouseContainer . addEventListener ( 'mouseout' , function ( ) {
164+ self . isMouseOver = false ;
165+ self . unhover ( ) ;
166+ } ) ;
167+ mouseContainer . addEventListener ( 'mouseover' , function ( ) {
168+ self . isMouseOver = true ;
169+ } ) ;
156170} ;
157171
158172proto . toImage = function ( format ) {
@@ -574,7 +588,7 @@ proto.draw = function() {
574588
575589 glplot . setDirty ( ) ;
576590 }
577- else if ( ! camera . panning ) {
591+ else if ( ! camera . panning && this . isMouseOver ) {
578592 this . selectBox . enabled = false ;
579593
580594 var size = fullLayout . _size ,
@@ -658,14 +672,20 @@ proto.draw = function() {
658672
659673 // Remove hover effects if we're not over a point OR
660674 // if we're zooming or panning (in which case result is not set)
661- if ( ! result && this . lastPickResult ) {
675+ if ( ! result ) {
676+ this . unhover ( ) ;
677+ }
678+
679+ glplot . draw ( ) ;
680+ } ;
681+
682+ proto . unhover = function ( ) {
683+ if ( this . lastPickResult ) {
662684 this . spikes . update ( { } ) ;
663685 this . lastPickResult = null ;
664686 this . graphDiv . emit ( 'plotly_unhover' ) ;
665687 Fx . loneUnhover ( this . svgContainer ) ;
666688 }
667-
668- glplot . draw ( ) ;
669689} ;
670690
671691proto . hoverFormatter = function ( axisName , val ) {
0 commit comments