@@ -587,6 +587,73 @@ describe('axis zoom/pan and main plot zoom', function() {
587
587
. catch ( failTest )
588
588
. then ( done ) ;
589
589
} ) ;
590
+
591
+ it ( 'should draw correct zoomboxes corners' , function ( done ) {
592
+ var dragCoverNode ;
593
+ var p1 ;
594
+
595
+ function _dragStart ( p0 , dp ) {
596
+ var node = getDragger ( 'xy' , 'nsew' ) ;
597
+ mouseEvent ( 'mousemove' , p0 [ 0 ] , p0 [ 1 ] , { element : node } ) ;
598
+ mouseEvent ( 'mousedown' , p0 [ 0 ] , p0 [ 1 ] , { element : node } ) ;
599
+
600
+ var promise = drag . waitForDragCover ( ) . then ( function ( dcn ) {
601
+ dragCoverNode = dcn ;
602
+ p1 = [ p0 [ 0 ] + dp [ 0 ] , p0 [ 1 ] + dp [ 1 ] ] ;
603
+ mouseEvent ( 'mousemove' , p1 [ 0 ] , p1 [ 1 ] , { element : dragCoverNode } ) ;
604
+ } ) ;
605
+ return promise ;
606
+ }
607
+
608
+ function _assertAndDragEnd ( msg , exp ) {
609
+ var zl = d3 . select ( gd ) . select ( 'g.zoomlayer' ) ;
610
+ var d = zl . select ( '.zoombox-corners' ) . attr ( 'd' ) ;
611
+
612
+ if ( exp . cornerCnt ) {
613
+ var actual = ( d . match ( / Z / g) || [ ] ) . length ;
614
+ expect ( actual ) . toBe ( exp . cornerCnt , 'zoombox corner cnt: ' + msg ) ;
615
+ } else {
616
+ expect ( d ) . toBe ( 'M0,0Z' , 'no zoombox corners: ' + msg ) ;
617
+ }
618
+
619
+ mouseEvent ( 'mouseup' , p1 [ 0 ] , p1 [ 1 ] , { element : dragCoverNode } ) ;
620
+ return drag . waitForDragCoverRemoval ( ) ;
621
+ }
622
+
623
+ Plotly . plot ( gd , [ { y : [ 1 , 2 , 1 ] } ] )
624
+ . then ( function ( ) { return _dragStart ( [ 170 , 170 ] , [ 30 , 30 ] ) ; } )
625
+ . then ( function ( ) {
626
+ return _assertAndDragEnd ( 'full-x full-y' , { cornerCnt : 4 } ) ;
627
+ } )
628
+ . then ( function ( ) { return _dragStart ( [ 170 , 170 ] , [ 5 , 30 ] ) ; } )
629
+ . then ( function ( ) {
630
+ return _assertAndDragEnd ( 'full-y' , { cornerCnt : 2 } ) ;
631
+ } )
632
+ . then ( function ( ) { return _dragStart ( [ 170 , 170 ] , [ 30 , 2 ] ) ; } )
633
+ . then ( function ( ) {
634
+ return _assertAndDragEnd ( 'full-x' , { cornerCnt : 2 } ) ;
635
+ } )
636
+ . then ( function ( ) { return Plotly . relayout ( gd , 'xaxis.fixedrange' , true ) ; } )
637
+ . then ( function ( ) { return _dragStart ( [ 170 , 170 ] , [ 30 , 30 ] ) ; } )
638
+ . then ( function ( ) {
639
+ return _assertAndDragEnd ( 'full-x full-y w/ fixed xaxis' , { cornerCnt : 2 } ) ;
640
+ } )
641
+ . then ( function ( ) { return _dragStart ( [ 170 , 170 ] , [ 30 , 5 ] ) ; } )
642
+ . then ( function ( ) {
643
+ return _assertAndDragEnd ( 'full-x w/ fixed xaxis' , { cornerCnt : 0 } ) ;
644
+ } )
645
+ . then ( function ( ) { return Plotly . relayout ( gd , { 'xaxis.fixedrange' : false , 'yaxis.fixedrange' : true } ) ; } )
646
+ . then ( function ( ) { return _dragStart ( [ 170 , 170 ] , [ 30 , 30 ] ) ; } )
647
+ . then ( function ( ) {
648
+ return _assertAndDragEnd ( 'full-x full-y w/ fixed yaxis' , { cornerCnt : 2 } ) ;
649
+ } )
650
+ . then ( function ( ) { return _dragStart ( [ 170 , 170 ] , [ 5 , 30 ] ) ; } )
651
+ . then ( function ( ) {
652
+ return _assertAndDragEnd ( 'full-y w/ fixed yaxis' , { cornerCnt : 0 } ) ;
653
+ } )
654
+ . catch ( failTest )
655
+ . then ( done ) ;
656
+ } ) ;
590
657
} ) ;
591
658
592
659
describe ( 'Event data:' , function ( ) {
0 commit comments