mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-19 23:14:47 +02:00
Class toolbars with narrow if we detect overflow happening
Also add css rules to drop labels from toolbar buttons if needed
This commit is contained in:
+13
-2
@@ -16,7 +16,6 @@ body {
|
||||
sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
min-width: 768px;
|
||||
color: #333;
|
||||
overflow: hidden;
|
||||
-ms-user-select: none;
|
||||
@@ -32,7 +31,6 @@ body {
|
||||
.id-container {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
min-width: 768px;
|
||||
}
|
||||
|
||||
#content {
|
||||
@@ -609,6 +607,19 @@ button.add-note svg.icon {
|
||||
}
|
||||
|
||||
|
||||
#bar.narrow .tool-group {
|
||||
width: unset;
|
||||
}
|
||||
#bar.narrow .spinner,
|
||||
#bar.narrow button .label {
|
||||
display: none;
|
||||
}
|
||||
#bar.narrow button .count {
|
||||
border-left-width: 0;
|
||||
border-right-width: 0;
|
||||
}
|
||||
|
||||
|
||||
/* Header for modals / panes
|
||||
------------------------------------------------------- */
|
||||
.header {
|
||||
|
||||
+29
-5
@@ -45,13 +45,9 @@ import { uiCmd } from './cmd';
|
||||
|
||||
|
||||
export function uiInit(context) {
|
||||
// Selectors for elements that can be collapsed if they overflow
|
||||
// (can't use a media query for this because it depends on sidebar width, not screen width)
|
||||
var headerCollapsable = 'button > span.label';
|
||||
var footerCollapsable = '';
|
||||
|
||||
var _initCounter = 0;
|
||||
var _initCallback;
|
||||
var _needWidth = {};
|
||||
|
||||
|
||||
function render(container) {
|
||||
@@ -400,7 +396,35 @@ export function uiInit(context) {
|
||||
map.dimensions(mapDimensions);
|
||||
|
||||
ui.photoviewer.onMapResize();
|
||||
|
||||
// check if header or footer have overflowed
|
||||
ui.checkOverflow('#bar');
|
||||
ui.checkOverflow('#footer');
|
||||
};
|
||||
|
||||
|
||||
// Call checkOverflow when resizing or whenever the contents change.
|
||||
ui.checkOverflow = function(selector, reset) {
|
||||
if (reset) {
|
||||
delete _needWidth[selector];
|
||||
}
|
||||
|
||||
var element = d3_select(selector);
|
||||
var scrollWidth = element.property('scrollWidth');
|
||||
var clientWidth = element.property('clientWidth');
|
||||
var needed = _needWidth[selector] || scrollWidth;
|
||||
|
||||
if (scrollWidth > clientWidth) { // overflow happening
|
||||
element.classed('narrow', true);
|
||||
if (!_needWidth[selector]) {
|
||||
_needWidth[selector] = scrollWidth;
|
||||
}
|
||||
|
||||
} else if (scrollWidth >= needed) {
|
||||
element.classed('narrow', false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return ui;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,11 @@ export function uiModes(context) {
|
||||
.attr('class', 'label')
|
||||
.text(function(mode) { return mode.title; });
|
||||
|
||||
// if we are adding/removing the buttons, check if toolbar has overflowed
|
||||
if (buttons.enter().size() || buttons.exit().size()) {
|
||||
context.ui().checkOverflow('#bar', true);
|
||||
}
|
||||
|
||||
// update
|
||||
buttons = buttons
|
||||
.merge(buttonsEnter)
|
||||
|
||||
Reference in New Issue
Block a user