@@ -371,6 +371,19 @@ describe('axis zoom/pan and main plot zoom', function() {
371
371
} ;
372
372
}
373
373
374
+ function doScroll ( subplot , directions , deltaY , opts ) {
375
+ return function ( ) {
376
+ opts = opts || { } ;
377
+ var edge = opts . edge || '' ;
378
+ var dx = opts . dx || 0 ;
379
+ var dy = opts . dy || 0 ;
380
+ var dragger = getDragger ( subplot , directions ) ;
381
+ var coords = getNodeCoords ( dragger , edge ) ;
382
+ mouseEvent ( 'scroll' , coords . x + dx , coords . y + dy , { deltaY : deltaY , element : dragger } ) ;
383
+ return delay ( constants . REDRAWDELAY + 10 ) ( ) ;
384
+ } ;
385
+ }
386
+
374
387
function checkRanges ( newRanges , msg ) {
375
388
msg = msg || '' ;
376
389
if ( msg ) msg = ' - ' + msg ;
@@ -459,26 +472,11 @@ describe('axis zoom/pan and main plot zoom', function() {
459
472
. then ( doDblClick ( 'x3y3' , 'nsew' ) )
460
473
. then ( checkRanges ( { } , 'reset x3y3' ) )
461
474
// scroll wheel
462
- . then ( function ( ) {
463
- var mainDrag = getDragger ( 'xy' , 'nsew' ) ;
464
- var mainDragCoords = getNodeCoords ( mainDrag , 'se' ) ;
465
- mouseEvent ( 'scroll' , mainDragCoords . x , mainDragCoords . y , { deltaY : 20 , element : mainDrag } ) ;
466
- } )
467
- . then ( delay ( constants . REDRAWDELAY + 10 ) )
475
+ . then ( doScroll ( 'xy' , 'nsew' , 20 , { edge : 'se' } ) )
468
476
. then ( checkRanges ( { xaxis : [ - 0.2103 , 2 ] , yaxis : [ 0 , 2.2103 ] } , 'xy main scroll' ) )
469
- . then ( function ( ) {
470
- var ewDrag = getDragger ( 'xy' , 'ew' ) ;
471
- var ewDragCoords = getNodeCoords ( ewDrag ) ;
472
- mouseEvent ( 'scroll' , ewDragCoords . x - 50 , ewDragCoords . y , { deltaY : - 20 , element : ewDrag } ) ;
473
- } )
474
- . then ( delay ( constants . REDRAWDELAY + 10 ) )
477
+ . then ( doScroll ( 'xy' , 'ew' , - 20 , { dx : - 50 } ) )
475
478
. then ( checkRanges ( { xaxis : [ - 0.1578 , 1.8422 ] , yaxis : [ 0 , 2.2103 ] } , 'x scroll' ) )
476
- . then ( function ( ) {
477
- var nsDrag = getDragger ( 'xy' , 'ns' ) ;
478
- var nsDragCoords = getNodeCoords ( nsDrag ) ;
479
- mouseEvent ( 'scroll' , nsDragCoords . x , nsDragCoords . y - 50 , { deltaY : - 20 , element : nsDrag } ) ;
480
- } )
481
- . then ( delay ( constants . REDRAWDELAY + 10 ) )
479
+ . then ( doScroll ( 'xy' , 'ns' , - 20 , { dy : - 50 } ) )
482
480
. then ( checkRanges ( { xaxis : [ - 0.1578 , 1.8422 ] , yaxis : [ 0.1578 , 2.1578 ] } , 'y scroll' ) )
483
481
. catch ( failTest )
484
482
. then ( done ) ;
@@ -512,20 +510,9 @@ describe('axis zoom/pan and main plot zoom', function() {
512
510
. then ( doDblClick ( 'xy' , 'nsew' ) )
513
511
. then ( checkRanges ( { } , 'dblclick xy #3' ) )
514
512
// scroll wheel
515
- . then ( function ( ) {
516
- var mainDrag = getDragger ( 'xy' , 'nsew' ) ;
517
- var mainDragCoords = getNodeCoords ( mainDrag , 'se' ) ;
518
- mouseEvent ( 'scroll' , mainDragCoords . x , mainDragCoords . y , { deltaY : 20 , element : mainDrag } ) ;
519
- } )
520
- . then ( delay ( constants . REDRAWDELAY + 10 ) )
521
- . then ( checkRanges ( { xaxis : [ - 0.2103 , 2 ] , yaxis : [ 0 , 2.2103 ] , xaxis2 : [ - 0.1052 , 2.1052 ] , yaxis2 : [ - 0.1052 , 2.1052 ] } ,
522
- 'scroll xy' ) )
523
- . then ( function ( ) {
524
- var ewDrag = getDragger ( 'xy' , 'ew' ) ;
525
- var ewDragCoords = getNodeCoords ( ewDrag ) ;
526
- mouseEvent ( 'scroll' , ewDragCoords . x - 50 , ewDragCoords . y , { deltaY : - 20 , element : ewDrag } ) ;
527
- } )
528
- . then ( delay ( constants . REDRAWDELAY + 10 ) )
513
+ . then ( doScroll ( 'xy' , 'nsew' , 20 , { edge : 'se' } ) )
514
+ . then ( checkRanges ( { xaxis : [ - 0.2103 , 2 ] , yaxis : [ 0 , 2.2103 ] , xaxis2 : [ - 0.1052 , 2.1052 ] , yaxis2 : [ - 0.1052 , 2.1052 ] } , 'scroll xy' ) )
515
+ . then ( doScroll ( 'xy' , 'ew' , - 20 , { dx : - 50 } ) )
529
516
. then ( checkRanges ( { xaxis : [ - 0.1578 , 1.8422 ] , yaxis : [ 0.1052 , 2.1052 ] } , 'scroll x' ) )
530
517
. catch ( failTest )
531
518
. then ( done ) ;
0 commit comments