HubSpot/tether — pull request #55 by chrisdarroch (2014-07-14 01:35:07+00:00)
Title: Cautious constraint

I wanted to use Tether's together constraint in a few places where it didn't work as I'd hoped: when there wasn't enough space on the configured side, the element would flip to the other side, but without checking if there was enough space there. In some configurations, it made it impossible to actually see the element. One such example are dropdowns for application menus where the dropdowns are possibly taller than the viewport.

To remedy this, I created a "cautious" constraint. It's an extension of the together constraint, with the additional behaviour of only swapping the attachment of an element+target if the user would be able to scroll the page (or container) to actually see the element. Another way of putting it is that the element won't ever disappear off the top or left-hand side of the browser window.