@@ -1247,6 +1247,70 @@ describe('Test polar interactions:', function() {
12471247 } ) ;
12481248 } ) ;
12491249 } ) ;
1250+
1251+ describe ( 'plotly_relayouting' , function ( ) {
1252+ afterEach ( destroyGraphDiv ) ;
1253+
1254+ [ 'zoom' ] . forEach ( function ( dragmode ) {
1255+ function _drag ( p0 , dp , nsteps ) {
1256+ var node = d3 . select ( '.polar > .draglayer > .maindrag' ) . node ( ) ;
1257+ return drag ( node , dp [ 0 ] , dp [ 1 ] , null , p0 [ 0 ] , p0 [ 1 ] , nsteps ) ;
1258+ }
1259+
1260+ it ( 'should emit plotly_relayouting events on ' + dragmode , function ( done ) {
1261+ var events = [ ] ; var path = [ [ 150 , 250 ] , [ 175 , 250 ] ] ; var relayoutCallback ;
1262+ var fig = Lib . extendDeep ( { } , require ( '@mocks/polar_scatter.json' ) ) ;
1263+ fig . layout . dragmode = dragmode ;
1264+
1265+ var gd = createGraphDiv ( ) ;
1266+ Plotly . plot ( gd , fig )
1267+ . then ( function ( ) {
1268+ relayoutCallback = jasmine . createSpy ( 'relayoutCallback' ) ;
1269+ gd . on ( 'plotly_relayout' , relayoutCallback ) ;
1270+ gd . on ( 'plotly_relayouting' , function ( e ) {
1271+ events . push ( e ) ;
1272+ } ) ;
1273+ return _drag ( path [ 0 ] , path [ 1 ] ) ;
1274+ } )
1275+ . then ( function ( ) {
1276+ expect ( events . length ) . toEqual ( path . length - 1 ) ;
1277+ expect ( events [ 0 ] [ 'polar.radialaxis.range' ] ) . toBeCloseToArray ( [ 6 , 11 ] , 0.1 ) ;
1278+ expect ( relayoutCallback ) . toHaveBeenCalledTimes ( 1 ) ;
1279+ } )
1280+ . catch ( failTest )
1281+ . then ( done ) ;
1282+ } ) ;
1283+ } ) ;
1284+ it ( 'should emit plotly_relayouting events on angular drag' , function ( done ) {
1285+ var events = [ ] ; var relayoutCallback ;
1286+ var fig = Lib . extendDeep ( { } , require ( '@mocks/polar_scatter.json' ) ) ;
1287+
1288+ function _drag ( p0 , dp , nsteps ) {
1289+ var node = d3 . select ( '.polar > .draglayer > .angulardrag' ) . node ( ) ;
1290+ return drag ( node , dp [ 0 ] , dp [ 1 ] , null , p0 [ 0 ] , p0 [ 1 ] , nsteps ) ;
1291+ }
1292+
1293+ var dragPos0 = [ 360 , 180 ] ;
1294+
1295+ var gd = createGraphDiv ( ) ;
1296+ Plotly . plot ( gd , fig )
1297+ . then ( function ( ) {
1298+ relayoutCallback = jasmine . createSpy ( 'relayoutCallback' ) ;
1299+ gd . on ( 'plotly_relayout' , relayoutCallback ) ;
1300+ gd . on ( 'plotly_relayouting' , function ( e ) {
1301+ events . push ( e ) ;
1302+ } ) ;
1303+ return _drag ( dragPos0 , [ 0 , - 110 ] , 10 ) ;
1304+ } )
1305+ . then ( function ( ) {
1306+ expect ( events . length ) . toEqual ( 10 ) ;
1307+ expect ( events . splice ( - 1 , 1 ) [ 0 ] [ 'polar.angularaxis.rotation' ] ) . toBeCloseTo ( 29 , 0 ) ;
1308+ expect ( relayoutCallback ) . toHaveBeenCalledTimes ( 1 ) ;
1309+ } )
1310+ . catch ( failTest )
1311+ . then ( done ) ;
1312+ } ) ;
1313+ } ) ;
12501314} ) ;
12511315
12521316describe ( 'Test polar *gridshape linear* interactions' , function ( ) {
0 commit comments