@@ -976,6 +976,51 @@ describe('@noCI, mapbox plots', function() {
976976 . then ( done ) ;
977977 } , LONG_TIMEOUT_INTERVAL ) ;
978978
979+ it ( 'should respect scrollZoom config option' , function ( done ) {
980+ var relayoutCnt = 0 ;
981+ gd . on ( 'plotly_relayout' , function ( ) { relayoutCnt ++ ; } ) ;
982+
983+ function _scroll ( ) {
984+ relayoutCnt = 0 ;
985+ return new Promise ( function ( resolve ) {
986+ mouseEvent ( 'mousemove' , pointPos [ 0 ] , pointPos [ 1 ] ) ;
987+ mouseEvent ( 'scroll' , pointPos [ 0 ] , pointPos [ 1 ] , { deltaY : - 400 } ) ;
988+ setTimeout ( resolve , 500 ) ;
989+ } ) ;
990+ }
991+
992+ var zoom = getMapInfo ( gd ) . zoom ;
993+ expect ( zoom ) . toBeCloseTo ( 1.234 ) ;
994+
995+ _scroll ( ) . then ( function ( ) {
996+ expect ( relayoutCnt ) . toBe ( 1 , 'scroll relayout cnt' ) ;
997+
998+ var zoomNew = getMapInfo ( gd ) . zoom ;
999+ expect ( zoomNew ) . toBeGreaterThan ( zoom ) ;
1000+ zoom = zoomNew ;
1001+ } )
1002+ . then ( function ( ) { return Plotly . plot ( gd , [ ] , { } , { scrollZoom : false } ) ; } )
1003+ . then ( _scroll )
1004+ . then ( function ( ) {
1005+ expect ( relayoutCnt ) . toBe ( 0 , 'no additional relayout call' ) ;
1006+
1007+ var zoomNew = getMapInfo ( gd ) . zoom ;
1008+ expect ( zoomNew ) . toBe ( zoom ) ;
1009+ zoom = zoomNew ;
1010+ } )
1011+ . then ( function ( ) { return Plotly . plot ( gd , [ ] , { } , { scrollZoom : true } ) ; } )
1012+ . then ( _scroll )
1013+ . then ( function ( ) {
1014+ expect ( relayoutCnt ) . toBe ( 1 , 'scroll relayout cnt' ) ;
1015+
1016+ var zoomNew = getMapInfo ( gd ) . zoom ;
1017+ expect ( zoomNew ) . toBeGreaterThan ( zoom ) ;
1018+ zoom = zoomNew ;
1019+ } )
1020+ . catch ( failTest )
1021+ . then ( done ) ;
1022+ } , LONG_TIMEOUT_INTERVAL ) ;
1023+
9791024 function getMapInfo ( gd ) {
9801025 var subplot = gd . _fullLayout . mapbox . _subplot ;
9811026 var map = subplot . map ;
0 commit comments