Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix responsive WebGL figures and modebar #3500

Merged
merged 3 commits into from Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/plotcss.js
Expand Up @@ -35,12 +35,12 @@ var rules = {
"X .ease-bg": "-webkit-transition:background-color 0.3s ease 0s;-moz-transition:background-color 0.3s ease 0s;-ms-transition:background-color 0.3s ease 0s;-o-transition:background-color 0.3s ease 0s;transition:background-color 0.3s ease 0s;",
"X .modebar--hover>:not(.watermark)": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;",
"X:hover .modebar--hover .modebar-group": "opacity:1;",
"X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;",
"X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;padding-left:8px;position:relative;vertical-align:middle;white-space:nowrap;",
"X .modebar-btn": "position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;",
"X .modebar-btn svg": "position:relative;top:2px;",
"X .modebar.vertical": "display:flex;flex-direction:column;flex-wrap:wrap;align-content:flex-end;max-height:100%;",
"X .modebar.vertical svg": "top:-1px;",
"X .modebar.vertical .modebar-group": "display:block;float:none;margin-left:0px;margin-bottom:8px;",
"X .modebar.vertical .modebar-group": "display:block;float:none;padding-left:0px;padding-bottom:8px;",
"X .modebar.vertical .modebar-group .modebar-btn": "display:block;text-align:center;",
"X [data-title]:before,X [data-title]:after": "position:absolute;-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);display:none;opacity:0;z-index:1001;pointer-events:none;top:110%;right:50%;",
"X [data-title]:hover:before,X [data-title]:hover:after": "display:block;opacity:1;",
Expand Down
4 changes: 2 additions & 2 deletions src/components/modebar/modebar.js
Expand Up @@ -64,7 +64,7 @@ proto.update = function(graphInfo, buttons) {
var bgSelector = context.displayModeBar === 'hover' ? '.js-plotly-plot .plotly:hover ' : '';

Lib.deleteRelatedStyleRule(modeBarId);
Lib.addRelatedStyleRule(modeBarId, bgSelector + '#' + modeBarId, 'background-color: ' + style.bgcolor);
Lib.addRelatedStyleRule(modeBarId, bgSelector + '#' + modeBarId + ' .modebar-group', 'background-color: ' + style.bgcolor);
Lib.addRelatedStyleRule(modeBarId, '#' + modeBarId + ' .modebar-btn .icon path', 'fill: ' + style.color);
Lib.addRelatedStyleRule(modeBarId, '#' + modeBarId + ' .modebar-btn:hover .icon path', 'fill: ' + style.activecolor);
Lib.addRelatedStyleRule(modeBarId, '#' + modeBarId + ' .modebar-btn.active .icon path', 'fill: ' + style.activecolor);
Expand Down Expand Up @@ -333,7 +333,7 @@ function createModeBar(gd, buttons) {

var modeBar = new ModeBar({
graphInfo: gd,
container: fullLayout._paperdiv.node(),
container: fullLayout._modebardiv.node(),
buttons: buttons
});

Expand Down
6 changes: 3 additions & 3 deletions src/css/_modebar.scss
Expand Up @@ -22,7 +22,7 @@
float: left;
display: inline-block;
box-sizing: border-box;
margin-left: 8px;
padding-left: 8px;
position: relative;
vertical-align: middle;
white-space: nowrap;
Expand Down Expand Up @@ -60,8 +60,8 @@
.modebar-group {
display: block;
float: none;
margin-left: 0px;
margin-bottom: 8px;
padding-left: 0px;
padding-bottom: 8px;

.modebar-btn {
display: block;
Expand Down
20 changes: 18 additions & 2 deletions src/plot_api/plot_api.js
Expand Up @@ -244,8 +244,6 @@ exports.plot = function(gd, data, layout, config) {
'position': 'absolute',
'top': 0,
'left': 0,
'width': '100%',
'height': '100%',
'overflow': 'visible',
'pointer-events': 'none'
});
Expand Down Expand Up @@ -279,6 +277,16 @@ exports.plot = function(gd, data, layout, config) {
}
}

if(fullLayout.modebar.orientation === 'h') {
fullLayout._modebardiv
.style('height', null)
.style('width', '100%');
} else {
fullLayout._modebardiv
.style('width', null)
.style('height', fullLayout.height + 'px');
}

return Plots.previousPromises(gd);
}

Expand Down Expand Up @@ -3845,5 +3853,13 @@ function makePlotFramework(gd) {
fullLayout._zoomlayer = fullLayout._toppaper.append('g').classed('zoomlayer', true);
fullLayout._hoverlayer = fullLayout._toppaper.append('g').classed('hoverlayer', true);

// Make the modebar container
fullLayout._modebardiv = fullLayout._paperdiv.selectAll('.modebar-container').data([0]);
fullLayout._modebardiv.enter().append('div')
.classed('modebar-container', true)
.style('position', 'absolute')
.style('top', '0px')
.style('right', '0px');

gd.emit('plotly_framework');
}