MCPcopy Create free account
hub / github.com/facebook/Rapid / checkOverflow

Method checkOverflow

modules/core/UiSystem.js:353–374  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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 /**

Callers 4

resizeMethod · 0.95
renderMethod · 0.80
renderMethod · 0.80
renderMethod · 0.80

Calls 1

containerMethod · 0.45

Tested by

no test coverage detected