Flip vertically if not enough room

Flip the vertical placement/alignment of the popover if it doesn't fit below/above and there's more room above/below.