I think there's a popover placement option which will do this for you, no? Or is that option only available in Bootstrap 3.x?