@@ -2824,3 +2824,81 @@ describe('plotly_relayouting', function() {
2824
2824
} ) ;
2825
2825
} ) ;
2826
2826
} ) ;
2827
+
2828
+
2829
+ describe ( 'minscale and maxscale' , function ( ) {
2830
+ function scroll ( pos , delta ) {
2831
+ return new Promise ( function ( resolve ) {
2832
+ mouseEvent ( 'mousemove' , pos [ 0 ] , pos [ 1 ] ) ;
2833
+ mouseEvent ( 'scroll' , pos [ 0 ] , pos [ 1 ] , { deltaX : delta [ 0 ] , deltaY : delta [ 1 ] } ) ;
2834
+ setTimeout ( resolve , 100 ) ;
2835
+ } ) ;
2836
+ }
2837
+
2838
+ var gd ;
2839
+
2840
+ beforeEach ( function ( ) { gd = createGraphDiv ( ) ; } ) ;
2841
+
2842
+ afterEach ( destroyGraphDiv ) ;
2843
+
2844
+ var allTests = [
2845
+ {
2846
+ name : 'non-clipped' ,
2847
+ mock : require ( '../../image/mocks/geo_winkel-tripel' )
2848
+ } ,
2849
+ {
2850
+ name : 'clipped' ,
2851
+ mock : require ( '../../image/mocks/geo_orthographic' )
2852
+ } ,
2853
+ {
2854
+ name : 'scoped' ,
2855
+ mock : require ( '../../image/mocks/geo_europe-bubbles' )
2856
+ }
2857
+ ] ;
2858
+
2859
+ allTests . forEach ( function ( test ) {
2860
+ it ( test . name + ' maxscale' , function ( done ) {
2861
+ var fig = Lib . extendDeep ( { } , test . mock ) ;
2862
+ fig . layout . width = 700 ;
2863
+ fig . layout . height = 500 ;
2864
+ fig . layout . dragmode = 'pan' ;
2865
+ if ( ! fig . layout . geo . projection ) fig . layout . geo . projection = { } ;
2866
+ fig . layout . geo . projection . maxscale = 1.2 ;
2867
+
2868
+ var initialScale ;
2869
+
2870
+ Plotly . newPlot ( gd , fig )
2871
+ . then ( function ( ) {
2872
+ initialScale = gd . _fullLayout . geo . _subplot . projection . scale ( ) ;
2873
+
2874
+ return scroll ( [ 200 , 250 ] , [ - 200 , - 200 ] ) ;
2875
+ } )
2876
+ . then ( function ( ) {
2877
+ expect ( gd . _fullLayout . geo . _subplot . projection . scale ( ) ) . toEqual ( 1.2 * initialScale ) ;
2878
+ } )
2879
+ . then ( done , done . fail ) ;
2880
+ } ) ;
2881
+
2882
+ it ( test . name + ' minscale' , function ( done ) {
2883
+ var fig = Lib . extendDeep ( { } , test . mock ) ;
2884
+ fig . layout . width = 700 ;
2885
+ fig . layout . height = 500 ;
2886
+ fig . layout . dragmode = 'pan' ;
2887
+ if ( ! fig . layout . geo . projection ) fig . layout . geo . projection = { } ;
2888
+ fig . layout . geo . projection . minscale = 0.8 ;
2889
+
2890
+ var initialScale ;
2891
+
2892
+ Plotly . newPlot ( gd , fig )
2893
+ . then ( function ( ) {
2894
+ initialScale = gd . _fullLayout . geo . _subplot . projection . scale ( ) ;
2895
+
2896
+ return scroll ( [ 200 , 250 ] , [ 200 , 200 ] ) ;
2897
+ } )
2898
+ . then ( function ( ) {
2899
+ expect ( gd . _fullLayout . geo . _subplot . projection . scale ( ) ) . toEqual ( 0.8 * initialScale ) ;
2900
+ } )
2901
+ . then ( done , done . fail ) ;
2902
+ } ) ;
2903
+ } ) ;
2904
+ } ) ;
0 commit comments