@@ -2730,6 +2730,83 @@ describe('Test geo zoom/pan/drag interactions:', function() {
27302730 } )
27312731 . then ( done , done . fail ) ;
27322732 } ) ;
2733+
2734+ describe ( 'minscale and maxscale' , ( ) => {
2735+ const defaultConfig = {
2736+ layout : {
2737+ dragmode : 'pan' ,
2738+ geo : { projection : { } } ,
2739+ height : 500 ,
2740+ width : 700
2741+ }
2742+ }
2743+ let gd ;
2744+
2745+ beforeEach ( ( ) => { gd = createGraphDiv ( ) ; } ) ;
2746+
2747+ afterEach ( destroyGraphDiv ) ;
2748+
2749+ const allTests = [
2750+ {
2751+ name : 'non-clipped' ,
2752+ mock : require ( '../../image/mocks/geo_winkel-tripel' )
2753+ } ,
2754+ {
2755+ name : 'clipped' ,
2756+ mock : require ( '../../image/mocks/geo_orthographic' )
2757+ } ,
2758+ {
2759+ name : 'scoped' ,
2760+ mock : require ( '../../image/mocks/geo_europe-bubbles' )
2761+ }
2762+ ] ;
2763+
2764+ allTests . forEach ( ( { mock, name } ) => {
2765+ it ( `${ name } maxscale` , done => {
2766+ const fig = Lib . extendDeep ( { } , mock , defaultConfig ) ;
2767+ fig . layout . geo . projection . maxscale = 1.2 ;
2768+
2769+ Plotly
2770+ . newPlot ( gd , fig )
2771+ // Zoom in far enough to hit limit
2772+ . then ( ( ) => scroll ( [ 200 , 250 ] , [ - 200 , - 200 ] ) )
2773+ . then ( ( ) => {
2774+ const maxScale = gd . _fullLayout . geo . _subplot . projection . scaleExtent ( ) [ 1 ] ;
2775+ expect ( gd . _fullLayout . geo . _subplot . projection . scale ( ) ) . toEqual ( maxScale ) ;
2776+ } )
2777+ . then ( done , done . fail ) ;
2778+ } ) ;
2779+
2780+ it ( `${ name } minscale` , done => {
2781+ const fig = Lib . extendDeep ( { } , mock , defaultConfig ) ;
2782+ fig . layout . geo . projection . minscale = 0.8 ;
2783+
2784+ Plotly
2785+ . newPlot ( gd , fig )
2786+ // Zoom out far enough to hit limit
2787+ . then ( ( ) => scroll ( [ 200 , 250 ] , [ 1000 , 1000 ] ) )
2788+ . then ( ( ) => {
2789+ const minScale = gd . _fullLayout . geo . _subplot . projection . scaleExtent ( ) [ 0 ] ;
2790+ expect ( gd . _fullLayout . geo . _subplot . projection . scale ( ) ) . toEqual ( minScale ) ;
2791+ } )
2792+ . then ( done , done . fail ) ;
2793+ } ) ;
2794+
2795+ it ( `${ name } minscale greater than 1` , done => {
2796+ const fig = Lib . extendDeep ( { } , mock , defaultConfig ) ;
2797+ fig . layout . geo . projection . minscale = 3 ;
2798+
2799+ Plotly
2800+ . newPlot ( gd , fig )
2801+ // The limit should already be hit during plot creation
2802+ . then ( ( ) => {
2803+ const minScale = gd . _fullLayout . geo . _subplot . projection . scaleExtent ( ) [ 0 ] ;
2804+ expect ( gd . _fullLayout . geo . _subplot . projection . scale ( ) ) . toEqual ( minScale ) ;
2805+ } )
2806+ . then ( done , done . fail ) ;
2807+ } ) ;
2808+ } ) ;
2809+ } ) ;
27332810} ) ;
27342811
27352812describe ( 'Test geo interactions update marker angles:' , function ( ) {
@@ -2824,81 +2901,3 @@ describe('plotly_relayouting', function() {
28242901 } ) ;
28252902 } ) ;
28262903} ) ;
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