@@ -2,6 +2,7 @@ var d3 = require('d3');
2
2
3
3
var Plotly = require ( '@lib/index' ) ;
4
4
var Fx = require ( '@src/plots/cartesian/graph_interact' ) ;
5
+ var constants = require ( '@src/plots/cartesian/constants' ) ;
5
6
var Lib = require ( '@src/lib' ) ;
6
7
7
8
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
@@ -605,3 +606,49 @@ describe('hover info on overlaid subplots', function() {
605
606
} ) . then ( done ) ;
606
607
} ) ;
607
608
} ) ;
609
+
610
+ describe ( 'hover after resizing' , function ( ) {
611
+ 'use strict' ;
612
+
613
+ afterEach ( destroyGraphDiv ) ;
614
+
615
+ function assertLabelCount ( pos , cnt , msg ) {
616
+ return new Promise ( function ( resolve ) {
617
+ mouseEvent ( 'mousemove' , pos [ 0 ] , pos [ 1 ] ) ;
618
+
619
+ setTimeout ( function ( ) {
620
+ var hoverText = d3 . selectAll ( 'g.hovertext' ) ;
621
+ expect ( hoverText . size ( ) ) . toEqual ( cnt , msg ) ;
622
+
623
+ resolve ( ) ;
624
+ } , constants . HOVERMINTIME ) ;
625
+ } ) ;
626
+ }
627
+
628
+ it ( 'should work' , function ( done ) {
629
+ var data = [ { y : [ 2 , 1 , 2 ] } ] ,
630
+ layout = { width : 600 , height : 500 } ,
631
+ gd = createGraphDiv ( ) ;
632
+
633
+ var pos0 = [ 311 , 409 ] ,
634
+ pos1 = [ 407 , 128 ] ;
635
+
636
+ Plotly . plot ( gd , data , layout ) . then ( function ( ) {
637
+ return assertLabelCount ( pos0 , 1 , 'before resize, showing pt label' ) ;
638
+ } ) . then ( function ( ) {
639
+ return assertLabelCount ( pos1 , 0 , 'before resize, not showing blank spot' ) ;
640
+ } ) . then ( function ( ) {
641
+ return Plotly . relayout ( gd , 'width' , 500 ) ;
642
+ } ) . then ( function ( ) {
643
+ return assertLabelCount ( pos0 , 0 , 'after resize, not showing blank spot' ) ;
644
+ } ) . then ( function ( ) {
645
+ return assertLabelCount ( pos1 , 1 , 'after resize, showing pt label' ) ;
646
+ } ) . then ( function ( ) {
647
+ return Plotly . relayout ( gd , 'width' , 600 ) ;
648
+ } ) . then ( function ( ) {
649
+ return assertLabelCount ( pos0 , 1 , 'back to initial, showing pt label' ) ;
650
+ } ) . then ( function ( ) {
651
+ return assertLabelCount ( pos1 , 0 , 'back to initial, not showing blank spot' ) ;
652
+ } ) . then ( done ) ;
653
+ } ) ;
654
+ } ) ;
0 commit comments