@@ -396,6 +396,60 @@ describe('zoom with drag', function() {
396
396
}
397
397
} ) ;
398
398
399
+ describe ( 'coordinate handling' , function ( ) {
400
+ it ( 'handles dragging to the right edge of the chart' , function ( ) {
401
+ chart = window . acquireChart ( {
402
+ type : 'line' ,
403
+ data,
404
+ options : {
405
+ scales : {
406
+ xScale0 : {
407
+ id : 'xScale0' ,
408
+ type : 'linear' ,
409
+ min : 0 ,
410
+ max : 4
411
+ } ,
412
+ yScale0 : {
413
+ id : 'yScale0' ,
414
+ type : 'linear' ,
415
+ min : 0 ,
416
+ max : 4 ,
417
+ }
418
+ } ,
419
+ plugins : {
420
+ zoom : {
421
+ zoom : {
422
+ drag : {
423
+ enabled : true
424
+ } ,
425
+ mode : 'xy'
426
+ }
427
+ }
428
+ }
429
+ }
430
+ } , {
431
+ wrapper : { style : 'position: absolute; left: 50px; top: 50px;' }
432
+ } ) ;
433
+
434
+ scaleX = chart . scales . xScale0 ;
435
+ scaleY = chart . scales . yScale0 ;
436
+
437
+ jasmine . triggerMouseEvent ( chart , 'mousedown' , {
438
+ x : scaleX . getPixelForValue ( 1.5 ) ,
439
+ y : scaleY . getPixelForValue ( 1.2 )
440
+ } ) ;
441
+ jasmine . triggerMouseEvent ( chart , 'mouseup' , {
442
+ x : scaleX . getPixelForValue ( 4 ) + 5 ,
443
+ y : scaleY . getPixelForValue ( 1.7 )
444
+ } ) ;
445
+
446
+ expect ( scaleX . options . min ) . toBeCloseTo ( 1.5 ) ;
447
+ expect ( scaleX . options . max ) . toBeCloseTo ( 4 ) ;
448
+ expect ( scaleY . options . min ) . toBeCloseTo ( 1.2 ) ;
449
+ expect ( scaleY . options . max ) . toBeCloseTo ( 1.7 ) ;
450
+ } ) ;
451
+ } ) ;
452
+
399
453
describe ( 'events' , function ( ) {
400
454
it ( 'should call onZoomStart, onZoom and onZoomComplete' , function ( done ) {
401
455
const startSpy = jasmine . createSpy ( 'start' ) ;
0 commit comments