Skip to content

Commit 91ce34f

Browse files
committed
make dragmode and hovermode attribute of each scenes:
- Use layout.dragmode and layout.hovermode as default for layout.scene?.dragmode and layout.scene?.hovermode if plot has only GL3D (backward compat) and if valid
1 parent fcdf05a commit 91ce34f

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

src/plots/cartesian/graph_interact.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ fx.layoutAttributes = {
2626
valType: 'enumerated',
2727
role: 'info',
2828
values: ['zoom', 'pan', 'select', 'lasso', 'orbit', 'turntable'],
29+
dflt: 'zoom',
2930
description: [
3031
'Determines the mode of drag interactions.',
3132
'*select* and *lasso* apply only to scatter traces with',
@@ -50,7 +51,7 @@ fx.supplyLayoutDefaults = function(layoutIn, layoutOut, fullData) {
5051
attr, dflt);
5152
}
5253

53-
coerce('dragmode', layoutOut._hasGL3D ? 'turntable' : 'zoom');
54+
coerce('dragmode');
5455

5556
if(layoutOut._hasCartesian) {
5657
// flag for 'horizontal' plots:

src/plots/gl3d/layout/defaults.js

+26-6
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,25 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
2929
return Lib.coerce(sceneLayoutIn, sceneLayoutOut, layoutAttributes, attr, dflt);
3030
}
3131

32+
// some layout-wide attribute are used in all scenes
33+
// if 3D is the only visible plot type
34+
function getDfltFromLayout(attr) {
35+
var isOnlyGL3D = !(
36+
layoutOut._hasCartesian ||
37+
layoutOut._hasGeo ||
38+
layoutOut._hasGL2D ||
39+
layoutOut._hasPie
40+
);
41+
42+
var isValid = layoutAttributes[attr].values.indexOf(layoutIn[attr]) !== -1;
43+
44+
var dflt;
45+
if(isOnlyGL3D && isValid) return layoutIn[attr];
46+
}
47+
3248
for(var i = 0; i < scenesLength; i++) {
3349
var scene = scenes[i];
50+
3451
/*
3552
* Scene numbering proceeds as follows
3653
* scene
@@ -85,18 +102,21 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
85102
if(aspectMode === 'manual') sceneLayoutOut.aspectmode = 'auto';
86103
}
87104

88-
/*
89-
* scene arrangements need to be implemented: For now just splice
90-
* along the horizontal direction. ie.
91-
* x:[0,1] -> x:[0,0.5], x:[0.5,1] ->
92-
* x:[0, 0.333] x:[0.333,0.666] x:[0.666, 1]
93-
*/
105+
/*
106+
* scene arrangements need to be implemented: For now just splice
107+
* along the horizontal direction. ie.
108+
* x:[0,1] -> x:[0,0.5], x:[0.5,1] ->
109+
* x:[0, 0.333] x:[0.333,0.666] x:[0.666, 1]
110+
*/
94111
supplyGl3dAxisLayoutDefaults(sceneLayoutIn, sceneLayoutOut, {
95112
font: layoutOut.font,
96113
scene: scene,
97114
data: fullData
98115
});
99116

117+
coerce('dragmode', getDfltFromLayout('dragmode'));
118+
coerce('hovermode', getDfltFromLayout('hovermode'));
119+
100120
layoutOut[scene] = sceneLayoutOut;
101121
}
102122
};

src/plots/gl3d/layout/layout_attributes.js

+19
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,25 @@ module.exports = {
139139
yaxis: gl3dAxisAttrs,
140140
zaxis: gl3dAxisAttrs,
141141

142+
dragmode: {
143+
valType: 'enumerated',
144+
role: 'info',
145+
values: ['orbit', 'turntable', 'zoom', 'pan'],
146+
dflt: 'turntable',
147+
description: [
148+
'Determines the mode of drag interactions for this scene.'
149+
].join(' ')
150+
},
151+
hovermode: {
152+
valType: 'enumerated',
153+
role: 'info',
154+
values: ['closest', false],
155+
dflt: 'closest',
156+
description: [
157+
'Determines the mode of hover interactions for this scene.'
158+
].join(' ')
159+
},
160+
142161
_deprecated: {
143162
cameraposition: {
144163
valType: 'info_array',

0 commit comments

Comments
 (0)