@@ -299,7 +299,7 @@ describe('zoom', function() {
299299 wheelEv [ key + 'Key' ] = true ;
300300 }
301301
302- await jasmine . triggerWheelEvent ( chart , wheelEv ) ;
302+ jasmine . triggerWheelEvent ( chart , wheelEv ) ;
303303
304304 if ( pressed ) {
305305 expect ( scaleX . options . min ) . not . toEqual ( oldMinX ) ;
@@ -315,6 +315,79 @@ describe('zoom', function() {
315315 }
316316 } ) ;
317317
318+ describe ( 'drag with pan.modifierKey' , function ( ) {
319+ for ( const key of [ 'ctrl' , 'alt' , 'shift' , 'meta' ] ) {
320+ for ( const pressed of [ true , false ] ) {
321+ let chart , scaleX , scaleY ;
322+ it ( `should ${ pressed ? 'not ' : '' } change ${ pressed ? 'without' : 'with' } key ${ key } ` , async function ( ) {
323+ const rejectedSpy = jasmine . createSpy ( 'zoomRejected' ) ;
324+ const clickSpy = jasmine . createSpy ( 'clicked' ) ;
325+ chart = window . acquireChart ( {
326+ type : 'line' ,
327+ data,
328+ options : {
329+ scales : {
330+ x : {
331+ type : 'linear' ,
332+ min : 0 ,
333+ max : 10
334+ } ,
335+ y : {
336+ type : 'linear'
337+ }
338+ } ,
339+ plugins : {
340+ zoom : {
341+ pan : {
342+ modifierKey : key ,
343+ } ,
344+ zoom : {
345+ enabled : true ,
346+ drag : true ,
347+ mode : 'x' ,
348+ onZoomRejected : rejectedSpy
349+ }
350+ }
351+ } ,
352+ onClick : clickSpy
353+ }
354+ } ) ;
355+
356+ scaleX = chart . scales . x ;
357+ scaleY = chart . scales . y ;
358+
359+ const oldMinX = scaleX . options . min ;
360+ const oldMaxX = scaleX . options . max ;
361+
362+ const pt = {
363+ x : scaleX . getPixelForValue ( 1.5 ) ,
364+ y : scaleY . getPixelForValue ( 1.1 ) ,
365+ } ;
366+ const pt2 = { x : pt . x + 20 , y : pt . y + 20 } ;
367+ const init = { } ;
368+ if ( pressed ) {
369+ init [ key + 'Key' ] = true ;
370+ }
371+
372+ jasmine . dispatchEvent ( chart , 'mousedown' , pt , init ) ;
373+ jasmine . dispatchEvent ( chart , 'mousemove' , pt2 , init ) ;
374+ jasmine . dispatchEvent ( chart , 'mouseup' , pt2 , init ) ;
375+
376+ if ( pressed ) {
377+ expect ( scaleX . options . min ) . toEqual ( oldMinX ) ;
378+ expect ( scaleX . options . max ) . toEqual ( oldMaxX ) ;
379+ expect ( rejectedSpy ) . toHaveBeenCalled ( ) ;
380+ } else {
381+ expect ( scaleX . options . min ) . not . toEqual ( oldMinX ) ;
382+ expect ( scaleX . options . max ) . not . toEqual ( oldMaxX ) ;
383+ expect ( rejectedSpy ) . not . toHaveBeenCalled ( ) ;
384+ }
385+ expect ( clickSpy ) . not . toHaveBeenCalled ( ) ;
386+ } ) ;
387+ }
388+ }
389+ } ) ;
390+
318391 describe ( 'with overScaleMode = y and mode = xy' , function ( ) {
319392 const config = {
320393 type : 'line' ,
0 commit comments