Needs:
I need a trigger for when the textContent of a button has overflowed it's button width.
Question:
Is there any concise/clever way to detect when textContent has overflow'd its parent?
UPDATED: Looks like this will solve my problem.
HTML:
<div class="container">
<button>a normal button</button>
<button>tiny</button>
<button class="parent">
<div class="child">a rhhh, really wide button lskdfjlasdkfj lksjd flaksjd flaskdjf lkj</div>
</button>
</div>
CSS:
.container {
display: inline-grid;
grid-template-columns: 1fr 1fr 1fr;
grid-column-gap: 20px;
}
.parent {
overflow: hidden;
}
button {
white-space: nowrap;
}
JS:
const child = document.querySelector('.child');
console.log(child.scrollWidth, 'child');
const parent = document.querySelector('.parent');
console.log(parent.clientWidth,'parent');
Note: I cannot rely on scroll bars. (UPDATED sorta use scrollbars)