@@ -67,6 +67,11 @@ function Scene2D(options, fullLayout) {
67
67
// last pick result
68
68
this . pickResult = null ;
69
69
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
+
70
75
this . bounds = [ Infinity , Infinity , - Infinity , - Infinity ] ;
71
76
72
77
// flag to stop render loop
@@ -153,6 +158,15 @@ proto.makeFramework = function() {
153
158
container . appendChild ( canvas ) ;
154
159
container . appendChild ( svgContainer ) ;
155
160
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
+ } ) ;
156
170
} ;
157
171
158
172
proto . toImage = function ( format ) {
@@ -574,7 +588,7 @@ proto.draw = function() {
574
588
575
589
glplot . setDirty ( ) ;
576
590
}
577
- else if ( ! camera . panning ) {
591
+ else if ( ! camera . panning && this . isMouseOver ) {
578
592
this . selectBox . enabled = false ;
579
593
580
594
var size = fullLayout . _size ,
@@ -658,14 +672,20 @@ proto.draw = function() {
658
672
659
673
// Remove hover effects if we're not over a point OR
660
674
// 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 ) {
662
684
this . spikes . update ( { } ) ;
663
685
this . lastPickResult = null ;
664
686
this . graphDiv . emit ( 'plotly_unhover' ) ;
665
687
Fx . loneUnhover ( this . svgContainer ) ;
666
688
}
667
-
668
- glplot . draw ( ) ;
669
689
} ;
670
690
671
691
proto . hoverFormatter = function ( axisName , val ) {
0 commit comments