* checkOverflow * Call checkOverflow when resizing or whenever the contents change. * I think this was to make button labels in the top bar disappear * when more buttons are added than the screen has available width * @param {string} selector - selector to select the thing to check
(selector, reset)
| 351 | * @param {string} selector - selector to select the thing to check |
| 352 | */ |
| 353 | checkOverflow(selector, reset) { |
| 354 | if (reset) { |
| 355 | delete this._needWidth[selector]; |
| 356 | } |
| 357 | |
| 358 | const $selection = this.context.container().select(selector); |
| 359 | if ($selection.empty()) return; |
| 360 | |
| 361 | const scrollWidth = $selection.property('scrollWidth'); |
| 362 | const clientWidth = $selection.property('clientWidth'); |
| 363 | let needed = this._needWidth[selector] || scrollWidth; |
| 364 | |
| 365 | if (scrollWidth > clientWidth) { // overflow happening |
| 366 | $selection.classed('narrow', true); |
| 367 | if (!this._needWidth[selector]) { |
| 368 | this._needWidth[selector] = scrollWidth; |
| 369 | } |
| 370 | |
| 371 | } else if (scrollWidth >= needed) { |
| 372 | $selection.classed('narrow', false); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | |
| 377 | /** |