Skip to content

Commit f8bf472

Browse files
committed
revised auto logic i.e. without touching layout inputs
1 parent d25c335 commit f8bf472

File tree

4 files changed

+26
-31
lines changed

4 files changed

+26
-31
lines changed

src/plots/gl3d/layout/defaults.js

+22-25
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,25 @@ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) {
9797
sceneLayoutIn.aspectmode = sceneLayoutOut.aspectmode;
9898
}
9999

100-
function enableTurnTable() {
101-
sceneLayoutIn.dragmode = 'turntable';
102-
}
100+
supplyGl3dAxisLayoutDefaults(sceneLayoutIn, sceneLayoutOut, {
101+
font: opts.font,
102+
scene: opts.id,
103+
data: opts.fullData,
104+
bgColor: bgColorCombined,
105+
calendar: opts.calendar,
106+
fullLayout: opts.fullLayout
107+
});
108+
109+
Registry.getComponentMethod('annotations3d', 'handleDefaults')(
110+
sceneLayoutIn, sceneLayoutOut, opts
111+
);
112+
113+
var dragmode = opts.getDfltFromLayout('dragmode');
103114

104-
if(sceneLayoutIn.dragmode !== false) {
105-
if(!sceneLayoutIn.dragmode) {
106-
// Because the default is now set to orbit mode
107-
// (i.e. in order to apply camera.z.up at init time)
108-
// we set turnable our disarable option here.
115+
if(dragmode !== false) {
116+
if(!dragmode) {
117+
118+
dragmode = 'orbit';
109119

110120
if(sceneLayoutIn.camera &&
111121
sceneLayoutIn.camera.up) {
@@ -115,29 +125,16 @@ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) {
115125
var z = sceneLayoutIn.camera.up.z;
116126

117127
if(!x || !y || !z) {
118-
enableTurnTable();
128+
dragmode = 'turntable';
119129
} else if(z / Math.sqrt(x * x + y * y + z * z) > 0.999) {
120-
enableTurnTable();
130+
dragmode = 'turntable';
121131
}
122132
} else {
123-
enableTurnTable();
133+
dragmode = 'turntable';
124134
}
125135
}
126136
}
127137

128-
supplyGl3dAxisLayoutDefaults(sceneLayoutIn, sceneLayoutOut, {
129-
font: opts.font,
130-
scene: opts.id,
131-
data: opts.fullData,
132-
bgColor: bgColorCombined,
133-
calendar: opts.calendar,
134-
fullLayout: opts.fullLayout
135-
});
136-
137-
Registry.getComponentMethod('annotations3d', 'handleDefaults')(
138-
sceneLayoutIn, sceneLayoutOut, opts
139-
);
140-
141-
coerce('dragmode', opts.getDfltFromLayout('dragmode'));
138+
coerce('dragmode', dragmode);
142139
coerce('hovermode', opts.getDfltFromLayout('hovermode'));
143140
}

src/plots/gl3d/layout/layout_attributes.js

-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ module.exports = {
140140
valType: 'enumerated',
141141
role: 'info',
142142
values: ['orbit', 'turntable', 'zoom', 'pan', false],
143-
dflt: 'orbit',
144143
editType: 'plot',
145144
description: [
146145
'Determines the mode of drag interactions for this scene.'

test/jasmine/tests/gl3d_plot_interact_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ describe('Test gl3d plots', function() {
523523

524524
it('@gl should be able to reversibly change trace type', function(done) {
525525
var _mock = Lib.extendDeep({}, mock2);
526-
var sceneLayout = { aspectratio: { x: 1, y: 1, z: 1 }, dragmode: 'turntable' };
526+
var sceneLayout = { aspectratio: { x: 1, y: 1, z: 1 } };
527527

528528
Plotly.plot(gd, _mock)
529529
.then(delay(20))

test/jasmine/tests/gl3dlayout_test.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe('Test Gl3d layout defaults', function() {
178178
layoutIn = { scene: {}, dragmode: 'orbit' };
179179
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
180180
expect(layoutOut.scene.dragmode)
181-
.toBe('turntable', 'to turntable if valid and 3d only');
181+
.toBe('orbit', 'to turntable if valid and 3d only');
182182

183183
layoutIn = { scene: {}, dragmode: 'invalid' };
184184
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
@@ -230,15 +230,14 @@ describe('Test Gl3d layout defaults', function() {
230230
.toBe('closest', 'to default if not valid');
231231
});
232232

233-
it('should add data-only scenes into layoutIn and also enable turntable', function() {
233+
it('should add data-only scenes into layoutIn', function() {
234234
layoutIn = {};
235235
fullData = [{ type: 'scatter3d', scene: 'scene' }];
236236

237237
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
238238
expect(layoutIn.scene).toEqual({
239239
aspectratio: { x: 1, y: 1, z: 1 },
240-
aspectmode: 'auto',
241-
dragmode: 'turntable'
240+
aspectmode: 'auto'
242241
});
243242
});
244243

0 commit comments

Comments
 (0)