Detect when list of divs "would be" overflowing

17 hours ago 3
ARTICLE AD BOX

I'm trying to find out whether a horizontal line of divs exceeds the width of their container. If they do, they should be displayed as a dropdown, as they are not allowed to overflow (and the divs should still be shown).

I've landed on requestAnimationFrame and summing each div's width ($div.getBoundingClientRect().width) to compare it with the parent's width. That works, but isn't very elegant. Is there a more event-driven way to get this done?

Read Entire Article