@@ -3632,6 +3632,55 @@ describe('hover updates', function() {
36323632 } )
36333633 . then ( done , done . fail ) ;
36343634 } ) ;
3635+
3636+ it ( 'drag should trigger unhover' , function ( done ) {
3637+ var data = [ { y : [ 1 ] } ] ;
3638+
3639+ var layout = {
3640+ hovermode : 'x' ,
3641+ width : 400 ,
3642+ height : 200 ,
3643+ margin : { l : 0 , t : 0 , r : 0 , b : 0 } ,
3644+ showlegend : false
3645+ } ;
3646+
3647+ var gd = createGraphDiv ( ) ;
3648+
3649+ var hoverHandler = jasmine . createSpy ( 'hover' ) ;
3650+ var unhoverHandler = jasmine . createSpy ( 'unhover' ) ;
3651+
3652+ var hoverPt = [ 200 , 100 ] ;
3653+ var dragPt = [ 210 , 100 ] ;
3654+
3655+ function hover ( ) {
3656+ mouseEvent ( 'mousemove' , hoverPt [ 0 ] , hoverPt [ 1 ] ) ;
3657+ Lib . clearThrottle ( ) ;
3658+ }
3659+
3660+ function drag ( ) {
3661+ mouseEvent ( 'mousedown' , hoverPt [ 0 ] , hoverPt [ 1 ] ) ;
3662+ mouseEvent ( 'mousemove' , dragPt [ 0 ] , dragPt [ 1 ] ) ;
3663+ mouseEvent ( 'mouseup' , dragPt [ 0 ] , dragPt [ 1 ] ) ;
3664+ Lib . clearThrottle ( ) ;
3665+ }
3666+
3667+ Plotly . react ( gd , data , layout )
3668+ . then ( function ( ) {
3669+ gd . on ( 'plotly_hover' , hoverHandler ) ;
3670+ gd . on ( 'plotly_unhover' , unhoverHandler ) ;
3671+ } )
3672+ . then ( hover )
3673+ . then ( function ( ) {
3674+ expect ( hoverHandler ) . toHaveBeenCalled ( ) ;
3675+ expect ( unhoverHandler ) . not . toHaveBeenCalled ( ) ;
3676+ } )
3677+ . then ( drag )
3678+ . then ( function ( ) {
3679+ expect ( hoverHandler ) . toHaveBeenCalled ( ) ;
3680+ expect ( unhoverHandler ) . toHaveBeenCalled ( ) ;
3681+ } )
3682+ . then ( done , done . fail ) ;
3683+ } ) ;
36353684} ) ;
36363685
36373686describe ( 'Test hover label custom styling:' , function ( ) {
0 commit comments