Skip to content

Commit 3b28fae

Browse files
committed
add few more tests to lock down the orthographic relayout issue
1 parent e4a30be commit 3b28fae

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

test/jasmine/tests/gl3d_plot_interact_test.js

+62
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,65 @@ describe('Test gl3d drag and wheel interactions', function() {
11751175
.then(done);
11761176
});
11771177

1178+
it('@gl should update the scene aspectratio when zooming with scroll wheel i.e. orthographic case', function(done) {
1179+
var sceneLayout, sceneLayout2, sceneTarget, sceneTarget2;
1180+
1181+
var mock = {
1182+
data: [
1183+
{ type: 'scatter3d', x: [1, 2, 3], y: [2, 3, 1], z: [3, 1, 2] },
1184+
{ type: 'surface', scene: 'scene2', x: [1, 2], y: [2, 1], z: [[1, 2], [2, 1]] }
1185+
],
1186+
layout: {
1187+
scene: { camera: { projection: {type: 'orthographic'}}},
1188+
scene2: { camera: { projection: {type: 'orthographic'}}, aspectratio: { x: 3, y: 2, z: 1 }}
1189+
}
1190+
};
1191+
1192+
var aspectratio;
1193+
var relayoutEvent;
1194+
var relayoutCnt = 0;
1195+
1196+
Plotly.plot(gd, mock)
1197+
.then(function() {
1198+
gd.on('plotly_relayout', function(e) {
1199+
relayoutCnt++;
1200+
relayoutEvent = e;
1201+
});
1202+
1203+
sceneLayout = gd._fullLayout.scene;
1204+
sceneLayout2 = gd._fullLayout.scene2;
1205+
sceneTarget = gd.querySelector('.svg-container .gl-container #scene canvas');
1206+
sceneTarget2 = gd.querySelector('.svg-container .gl-container #scene2 canvas');
1207+
1208+
expect(sceneLayout.aspectratio).toEqual({x: 1, y: 1, z: 1});
1209+
expect(sceneLayout2.aspectratio).toEqual({x: 3, y: 2, z: 1});
1210+
})
1211+
.then(function() {
1212+
return scroll(sceneTarget);
1213+
})
1214+
.then(function() {
1215+
expect(relayoutCnt).toEqual(1);
1216+
1217+
aspectratio = relayoutEvent['scene.aspectratio'];
1218+
expect(aspectratio.x).toBeCloseTo(0.909, 3, 'aspectratio.x');
1219+
expect(aspectratio.y).toBeCloseTo(0.909, 3, 'aspectratio.y');
1220+
expect(aspectratio.z).toBeCloseTo(0.909, 3, 'aspectratio.z');
1221+
})
1222+
.then(function() {
1223+
return scroll(sceneTarget2);
1224+
})
1225+
.then(function() {
1226+
expect(relayoutCnt).toEqual(2);
1227+
1228+
aspectratio = relayoutEvent['scene2.aspectratio'];
1229+
expect(aspectratio.x).toBeCloseTo(2.727, 3, 'aspectratio.x');
1230+
expect(aspectratio.y).toBeCloseTo(1.818, 3, 'aspectratio.y');
1231+
expect(aspectratio.z).toBeCloseTo(0.909, 3, 'aspectratio.z');
1232+
})
1233+
.catch(failTest)
1234+
.then(done);
1235+
});
1236+
11781237
it('@gl should fire plotly_relayouting events when dragged - perspective case', function(done) {
11791238
var sceneTarget, relayoutEvent;
11801239

@@ -1216,8 +1275,10 @@ describe('Test gl3d drag and wheel interactions', function() {
12161275
.then(function() {
12171276
expect(events.length).toEqual(nsteps);
12181277
expect(relayoutCnt).toEqual(1);
1278+
12191279
Object.keys(relayoutEvent).sort().forEach(function(key) {
12201280
expect(Object.keys(events[0])).toContain(key);
1281+
expect(key).not.toBe('scene.aspectratio');
12211282
});
12221283
})
12231284
.catch(failTest)
@@ -1267,6 +1328,7 @@ describe('Test gl3d drag and wheel interactions', function() {
12671328
expect(relayoutCnt).toEqual(1);
12681329
Object.keys(relayoutEvent).sort().forEach(function(key) {
12691330
expect(Object.keys(events[0])).toContain(key);
1331+
expect(key).not.toBe('scene.aspectratio');
12701332
});
12711333
})
12721334
.catch(failTest)

0 commit comments

Comments
 (0)