@@ -584,6 +584,53 @@ describe('@noCI, mapbox plots', function() {
584584 . then ( done ) ;
585585 } , LONG_TIMEOUT_INTERVAL ) ;
586586
587+ it ( '@gl should not update center while dragging' , function ( done ) {
588+ var map = gd . _fullLayout . mapbox . _subplot . map ;
589+ spyOn ( map , 'setCenter' ) . and . callThrough ( ) ;
590+
591+ var p1 = [ pointPos [ 0 ] + 50 , pointPos [ 1 ] - 20 ] ;
592+
593+ _mouseEvent ( 'mousemove' , pointPos , noop ) . then ( function ( ) {
594+ return Plotly . relayout ( gd , { 'mapbox.center' : { lon : 13.5 , lat : - 19.5 } } ) ;
595+ } ) . then ( function ( ) {
596+ // First relayout on mapbox.center results in setCenter call
597+ expect ( map . setCenter ) . toHaveBeenCalledWith ( [ 13.5 , - 19.5 ] ) ;
598+ expect ( map . setCenter ) . toHaveBeenCalledTimes ( 1 ) ;
599+ } ) . then ( function ( ) {
600+ return _mouseEvent ( 'mousedown' , pointPos , noop ) ;
601+ } ) . then ( function ( ) {
602+ return _mouseEvent ( 'mousemove' , p1 , noop ) ;
603+ } ) . then ( function ( ) {
604+ return Plotly . relayout ( gd , { 'mapbox.center' : { lat : 0 , lon : 0 } } ) ;
605+ } ) . then ( function ( ) {
606+ return _mouseEvent ( 'mouseup' , p1 , noop ) ;
607+ } ) . then ( function ( ) {
608+ // Second relayout on mapbox.center does not result in a setCenter
609+ // call since map drag is underway
610+ expect ( map . setCenter ) . toHaveBeenCalledTimes ( 1 ) ;
611+ } ) . then ( done ) ;
612+ } , LONG_TIMEOUT_INTERVAL ) ;
613+
614+ it ( '@gl should not update zoom while scroll wheeling' , function ( done ) {
615+ var map = gd . _fullLayout . mapbox . _subplot . map ;
616+ spyOn ( map , 'setZoom' ) . and . callThrough ( ) ;
617+
618+ _mouseEvent ( 'mousemove' , pointPos , noop ) . then ( function ( ) {
619+ return Plotly . relayout ( gd , { 'mapbox.zoom' : 5 } ) ;
620+ } ) . then ( function ( ) {
621+ // First relayout on mapbox.zoom results in setZoom call
622+ expect ( map . setZoom ) . toHaveBeenCalledWith ( 5 ) ;
623+ expect ( map . setZoom ) . toHaveBeenCalledTimes ( 1 ) ;
624+ } ) . then ( function ( ) {
625+ mouseEvent ( 'scroll' , pointPos [ 0 ] , pointPos [ 1 ] , { deltaY : - 400 } ) ;
626+ return Plotly . relayout ( gd , { 'mapbox.zoom' : 2 } ) . then ( function ( ) {
627+ // Second relayout on mapbox.zoom does not result in setZoom
628+ // call since a scroll wheel zoom is underway
629+ expect ( map . setZoom ) . toHaveBeenCalledTimes ( 1 ) ;
630+ } ) ;
631+ } ) . then ( done ) ;
632+ } , LONG_TIMEOUT_INTERVAL ) ;
633+
587634 it ( '@gl should be able to restyle' , function ( done ) {
588635 var restyleCnt = 0 ;
589636 var relayoutCnt = 0 ;
0 commit comments