@@ -1870,4 +1870,64 @@ describe('Test Plotly.react + interactions under uirevision:', function() {
18701870 . catch ( failTest )
18711871 . then ( done ) ;
18721872 } ) ;
1873+
1874+ it ( 'geo subplots should preserve viewport changes after panning' , function ( done ) {
1875+ function _react ( ) {
1876+ return Plotly . react ( gd , [ {
1877+ type : 'scattergeo' ,
1878+ lon : [ 3 , 1 , 2 ] ,
1879+ lat : [ 2 , 3 , 1 ]
1880+ } ] , {
1881+ width : 500 ,
1882+ height : 500 ,
1883+ uirevision : true
1884+ } ) ;
1885+ }
1886+
1887+ function _drag ( x0 , y0 , dx , dy ) {
1888+ mouseEvent ( 'mousemove' , x0 , y0 ) ;
1889+ mouseEvent ( 'mousedown' , x0 , y0 ) ;
1890+ mouseEvent ( 'mousemove' , x0 + dx , y0 + dy ) ;
1891+ mouseEvent ( 'mouseup' , x0 + dx , y0 + dy ) ;
1892+ }
1893+
1894+ // should be same before & after 2nd react()
1895+ function _assertGUI ( msg ) {
1896+ var TOL = 2 ;
1897+
1898+ var geo = gd . layout . geo || { } ;
1899+ expect ( ( ( geo . projection || { } ) . rotation || { } ) . lon ) . toBeCloseTo ( - 52.94 , TOL , msg ) ;
1900+ expect ( ( geo . center || { } ) . lon ) . toBeCloseTo ( - 52.94 , TOL , msg ) ;
1901+ expect ( ( geo . center || { } ) . lat ) . toBeCloseTo ( 52.94 , TOL , msg ) ;
1902+
1903+ var fullGeo = gd . _fullLayout . geo ;
1904+ expect ( fullGeo . projection . rotation . lon ) . toBeCloseTo ( - 52.94 , TOL , msg ) ;
1905+ expect ( fullGeo . center . lon ) . toBeCloseTo ( - 52.94 , TOL , msg ) ;
1906+ expect ( fullGeo . center . lat ) . toBeCloseTo ( 52.94 , TOL , msg ) ;
1907+
1908+ var preGUI = gd . _fullLayout . _preGUI ;
1909+ expect ( preGUI [ 'geo.projection.rotation.lon' ] ) . toBe ( null , msg ) ;
1910+ expect ( preGUI [ 'geo.center.lon' ] ) . toBe ( null , msg ) ;
1911+ expect ( preGUI [ 'geo.center.lat' ] ) . toBe ( null , msg ) ;
1912+ expect ( preGUI [ 'geo.projection.scale' ] ) . toBe ( null , msg ) ;
1913+ }
1914+
1915+ _react ( )
1916+ . then ( function ( ) {
1917+ expect ( gd . layout . geo ) . toEqual ( { } ) ;
1918+
1919+ var fullGeo = gd . _fullLayout . geo ;
1920+ expect ( fullGeo . projection . rotation . lon ) . toBe ( 0 ) ;
1921+ expect ( fullGeo . center . lon ) . toBe ( 0 ) ;
1922+ expect ( fullGeo . center . lat ) . toBe ( 0 ) ;
1923+
1924+ expect ( gd . _fullLayout . _preGUI ) . toEqual ( { } ) ;
1925+ } )
1926+ . then ( function ( ) { return _drag ( 200 , 200 , 50 , 50 ) ; } )
1927+ . then ( function ( ) { _assertGUI ( 'before' ) ; } )
1928+ . then ( _react )
1929+ . then ( function ( ) { _assertGUI ( 'after' ) ; } )
1930+ . catch ( failTest )
1931+ . then ( done ) ;
1932+ } ) ;
18731933} ) ;
0 commit comments