Partial protection from popover overflowing viewport.

This makes sure popover don't overflow viewport in top/left direction.