@@ -575,13 +575,19 @@ describe('Test gl3d modebar handlers - perspective case', function() {
575
575
buttonDefault . click ( ) ;
576
576
} ) ;
577
577
578
- it ( '@gl button resetCameraDefault3d should reset to initial aspectratios' , function ( done ) {
578
+ it ( '@gl button resetCameraDefault3d should reset to initial aspectmode & aspectratios' , function ( done ) {
579
579
var buttonDefault = selectButton ( modeBar , 'resetCameraDefault3d' ) ;
580
580
581
+ expect ( gd . _fullLayout . scene . _scene . viewInitial . aspectmode ) . toEqual ( 'auto' ) ;
582
+ expect ( gd . _fullLayout . scene2 . _scene . viewInitial . aspectmode ) . toEqual ( 'manual' ) ;
583
+
581
584
expect ( gd . _fullLayout . scene . _scene . viewInitial . aspectratio ) . toEqual ( { x : 1 , y : 1 , z : 1 } ) ;
582
585
expect ( gd . _fullLayout . scene2 . _scene . viewInitial . aspectratio ) . toEqual ( { x : 3 , y : 2 , z : 1 } ) ;
583
586
584
587
gd . once ( 'plotly_relayout' , function ( ) {
588
+ expect ( gd . _fullLayout . scene . _scene . fullSceneLayout . aspectmode ) . toBe ( 'auto' ) ;
589
+ expect ( gd . _fullLayout . scene2 . _scene . fullSceneLayout . aspectmode ) . toBe ( 'manual' ) ;
590
+
585
591
expect ( gd . _fullLayout . scene . _scene . glplot . getAspectratio ( ) . x ) . toBeCloseTo ( 1 ) ;
586
592
expect ( gd . _fullLayout . scene . _scene . glplot . getAspectratio ( ) . y ) . toBeCloseTo ( 1 ) ;
587
593
expect ( gd . _fullLayout . scene . _scene . glplot . getAspectratio ( ) . z ) . toBeCloseTo ( 1 ) ;
@@ -595,9 +601,12 @@ describe('Test gl3d modebar handlers - perspective case', function() {
595
601
buttonDefault . click ( ) ;
596
602
} ) ;
597
603
598
- it ( '@gl button resetCameraLastSave3d should reset to initial aspectratios' , function ( done ) {
604
+ it ( '@gl button resetCameraLastSave3d should reset to initial aspectmode & aspectratios' , function ( done ) {
599
605
var buttonDefault = selectButton ( modeBar , 'resetCameraDefault3d' ) ;
600
606
607
+ expect ( gd . _fullLayout . scene . _scene . viewInitial . aspectmode ) . toEqual ( 'auto' ) ;
608
+ expect ( gd . _fullLayout . scene2 . _scene . viewInitial . aspectmode ) . toEqual ( 'manual' ) ;
609
+
601
610
expect ( gd . _fullLayout . scene . _scene . viewInitial . aspectratio ) . toEqual ( { x : 1 , y : 1 , z : 1 } ) ;
602
611
expect ( gd . _fullLayout . scene2 . _scene . viewInitial . aspectratio ) . toEqual ( { x : 3 , y : 2 , z : 1 } ) ;
603
612
@@ -771,13 +780,19 @@ describe('Test gl3d modebar handlers - orthographic case', function() {
771
780
buttonDefault . click ( ) ;
772
781
} ) ;
773
782
774
- it ( '@gl button resetCameraDefault3d should reset to initial aspectratios' , function ( done ) {
783
+ it ( '@gl button resetCameraDefault3d should reset to initial aspectmode & aspectratios' , function ( done ) {
775
784
var buttonDefault = selectButton ( modeBar , 'resetCameraDefault3d' ) ;
776
785
786
+ expect ( gd . _fullLayout . scene . _scene . viewInitial . aspectmode ) . toEqual ( 'auto' ) ;
787
+ expect ( gd . _fullLayout . scene2 . _scene . viewInitial . aspectmode ) . toEqual ( 'manual' ) ;
788
+
777
789
expect ( gd . _fullLayout . scene . _scene . viewInitial . aspectratio ) . toEqual ( { x : 1 , y : 1 , z : 1 } ) ;
778
790
expect ( gd . _fullLayout . scene2 . _scene . viewInitial . aspectratio ) . toEqual ( { x : 3 , y : 2 , z : 1 } ) ;
779
791
780
792
gd . once ( 'plotly_relayout' , function ( ) {
793
+ expect ( gd . _fullLayout . scene . _scene . aspectmode ) . toEqual ( undefined ) ;
794
+ expect ( gd . _fullLayout . scene2 . _scene . aspectmode ) . toEqual ( undefined ) ;
795
+
781
796
expect ( gd . _fullLayout . scene . _scene . glplot . getAspectratio ( ) . x ) . toBeCloseTo ( 1 ) ;
782
797
expect ( gd . _fullLayout . scene . _scene . glplot . getAspectratio ( ) . y ) . toBeCloseTo ( 1 ) ;
783
798
expect ( gd . _fullLayout . scene . _scene . glplot . getAspectratio ( ) . z ) . toBeCloseTo ( 1 ) ;
@@ -791,13 +806,19 @@ describe('Test gl3d modebar handlers - orthographic case', function() {
791
806
buttonDefault . click ( ) ;
792
807
} ) ;
793
808
794
- it ( '@gl button resetCameraLastSave3d should reset to initial aspectratios' , function ( done ) {
809
+ it ( '@gl button resetCameraLastSave3d should reset to initial aspectmode & aspectratios' , function ( done ) {
795
810
var buttonDefault = selectButton ( modeBar , 'resetCameraDefault3d' ) ;
796
811
812
+ expect ( gd . _fullLayout . scene . _scene . viewInitial . aspectmode ) . toEqual ( 'auto' ) ;
813
+ expect ( gd . _fullLayout . scene2 . _scene . viewInitial . aspectmode ) . toEqual ( 'manual' ) ;
814
+
797
815
expect ( gd . _fullLayout . scene . _scene . viewInitial . aspectratio ) . toEqual ( { x : 1 , y : 1 , z : 1 } ) ;
798
816
expect ( gd . _fullLayout . scene2 . _scene . viewInitial . aspectratio ) . toEqual ( { x : 3 , y : 2 , z : 1 } ) ;
799
817
800
818
gd . once ( 'plotly_relayout' , function ( ) {
819
+ expect ( gd . _fullLayout . scene . _scene . fullSceneLayout . aspectmode ) . toBe ( 'auto' ) ;
820
+ expect ( gd . _fullLayout . scene2 . _scene . fullSceneLayout . aspectmode ) . toBe ( 'manual' ) ;
821
+
801
822
expect ( gd . _fullLayout . scene . _scene . glplot . getAspectratio ( ) . x ) . toBeCloseTo ( 1 ) ;
802
823
expect ( gd . _fullLayout . scene . _scene . glplot . getAspectratio ( ) . y ) . toBeCloseTo ( 1 ) ;
803
824
expect ( gd . _fullLayout . scene . _scene . glplot . getAspectratio ( ) . z ) . toBeCloseTo ( 1 ) ;
@@ -1175,7 +1196,7 @@ describe('Test gl3d drag and wheel interactions', function() {
1175
1196
. then ( done ) ;
1176
1197
} ) ;
1177
1198
1178
- it ( '@gl should update the scene aspectratio when zooming with scroll wheel i.e. orthographic case' , function ( done ) {
1199
+ it ( '@gl should update the scene aspectmode & aspectratio when zooming with scroll wheel i.e. orthographic case' , function ( done ) {
1179
1200
var sceneLayout , sceneLayout2 , sceneTarget , sceneTarget2 ;
1180
1201
1181
1202
var mock = {
@@ -1192,8 +1213,13 @@ describe('Test gl3d drag and wheel interactions', function() {
1192
1213
var aspectratio ;
1193
1214
var relayoutEvent ;
1194
1215
var relayoutCnt = 0 ;
1216
+ var modeBar ;
1195
1217
1196
1218
Plotly . plot ( gd , mock )
1219
+ . then ( delay ( 20 ) )
1220
+ . then ( function ( ) {
1221
+ modeBar = gd . _fullLayout . _modeBar ;
1222
+ } )
1197
1223
. then ( function ( ) {
1198
1224
gd . on ( 'plotly_relayout' , function ( e ) {
1199
1225
relayoutCnt ++ ;
@@ -1218,6 +1244,9 @@ describe('Test gl3d drag and wheel interactions', function() {
1218
1244
expect ( aspectratio . x ) . toBeCloseTo ( 0.909 , 3 , 'aspectratio.x' ) ;
1219
1245
expect ( aspectratio . y ) . toBeCloseTo ( 0.909 , 3 , 'aspectratio.y' ) ;
1220
1246
expect ( aspectratio . z ) . toBeCloseTo ( 0.909 , 3 , 'aspectratio.z' ) ;
1247
+
1248
+ expect ( relayoutEvent [ 'scene.aspectmode' ] ) . toBe ( 'manual' ) ;
1249
+ expect ( gd . _fullLayout . scene . _scene . fullSceneLayout . aspectmode ) . toBe ( 'manual' ) ;
1221
1250
} )
1222
1251
. then ( function ( ) {
1223
1252
return scroll ( sceneTarget2 ) ;
@@ -1229,6 +1258,25 @@ describe('Test gl3d drag and wheel interactions', function() {
1229
1258
expect ( aspectratio . x ) . toBeCloseTo ( 2.727 , 3 , 'aspectratio.x' ) ;
1230
1259
expect ( aspectratio . y ) . toBeCloseTo ( 1.818 , 3 , 'aspectratio.y' ) ;
1231
1260
expect ( aspectratio . z ) . toBeCloseTo ( 0.909 , 3 , 'aspectratio.z' ) ;
1261
+
1262
+ expect ( relayoutEvent [ 'scene2.aspectmode' ] ) . toBe ( 'manual' ) ;
1263
+ expect ( gd . _fullLayout . scene2 . _scene . fullSceneLayout . aspectmode ) . toBe ( 'manual' ) ;
1264
+ } )
1265
+ . then ( function ( ) {
1266
+ var buttonDefault = selectButton ( modeBar , 'resetCameraDefault3d' ) ;
1267
+
1268
+ buttonDefault . click ( ) ;
1269
+ } )
1270
+ . then ( function ( ) {
1271
+ expect ( gd . _fullLayout . scene . _scene . aspectmode ) . toEqual ( undefined ) ;
1272
+ expect ( gd . _fullLayout . scene2 . _scene . aspectmode ) . toEqual ( undefined ) ;
1273
+
1274
+ expect ( gd . _fullLayout . scene . _scene . glplot . getAspectratio ( ) . x ) . toBeCloseTo ( 1 ) ;
1275
+ expect ( gd . _fullLayout . scene . _scene . glplot . getAspectratio ( ) . y ) . toBeCloseTo ( 1 ) ;
1276
+ expect ( gd . _fullLayout . scene . _scene . glplot . getAspectratio ( ) . z ) . toBeCloseTo ( 1 ) ;
1277
+ expect ( gd . _fullLayout . scene2 . _scene . glplot . getAspectratio ( ) . x ) . toBeCloseTo ( 3 ) ;
1278
+ expect ( gd . _fullLayout . scene2 . _scene . glplot . getAspectratio ( ) . y ) . toBeCloseTo ( 2 ) ;
1279
+ expect ( gd . _fullLayout . scene2 . _scene . glplot . getAspectratio ( ) . z ) . toBeCloseTo ( 1 ) ;
1232
1280
} )
1233
1281
. catch ( failTest )
1234
1282
. then ( done ) ;
@@ -1279,6 +1327,7 @@ describe('Test gl3d drag and wheel interactions', function() {
1279
1327
Object . keys ( relayoutEvent ) . sort ( ) . forEach ( function ( key ) {
1280
1328
expect ( Object . keys ( events [ 0 ] ) ) . toContain ( key ) ;
1281
1329
expect ( key ) . not . toBe ( 'scene.aspectratio' ) ;
1330
+ expect ( key ) . not . toBe ( 'scene.aspectmode' ) ;
1282
1331
} ) ;
1283
1332
} )
1284
1333
. catch ( failTest )
@@ -1329,6 +1378,7 @@ describe('Test gl3d drag and wheel interactions', function() {
1329
1378
Object . keys ( relayoutEvent ) . sort ( ) . forEach ( function ( key ) {
1330
1379
expect ( Object . keys ( events [ 0 ] ) ) . toContain ( key ) ;
1331
1380
expect ( key ) . not . toBe ( 'scene.aspectratio' ) ;
1381
+ expect ( key ) . not . toBe ( 'scene.aspectmode' ) ;
1332
1382
} ) ;
1333
1383
} )
1334
1384
. catch ( failTest )
@@ -1456,6 +1506,9 @@ describe('Test gl3d drag and wheel interactions', function() {
1456
1506
expect ( aspectratio . x ) . toBeCloseTo ( 0.816 , 3 , 'aspectratio.x' ) ;
1457
1507
expect ( aspectratio . y ) . toBeCloseTo ( 0.725 , 3 , 'aspectratio.y' ) ;
1458
1508
expect ( aspectratio . z ) . toBeCloseTo ( 1.269 , 3 , 'aspectratio.z' ) ;
1509
+
1510
+ expect ( relayoutEvent [ 'scene.aspectmode' ] ) . toBe ( 'manual' ) ;
1511
+ expect ( gd . _fullLayout . scene . _scene . fullSceneLayout . aspectmode ) . toBe ( 'manual' ) ;
1459
1512
} )
1460
1513
. then ( function ( ) {
1461
1514
// select a point
0 commit comments