Pure position computation for a popover anchored to the mouse cursor.
The popover is placed just to the right/below the cursor (offset px away,
so it never covers the cursor). For each axis independently, if that
placement would overflow the viewport, try flipping to the left/above the
cursor — but only if the flipped position is in-bounds (>= gutter). If the
flip would also overflow, fall back to the original right/below placement
(the popover is then allowed to overflow the viewport edge — better than
placing it far from the cursor).
All popovers in this plugin are triggered by hover, so the cursor position
is always recorded at trigger time and passed in; the target element's
rectangle is intentionally NOT part of the computation.
Pure position computation for a popover anchored to the mouse cursor.
The popover is placed just to the right/below the cursor (offset px away, so it never covers the cursor). For each axis independently, if that placement would overflow the viewport, try flipping to the left/above the cursor — but only if the flipped position is in-bounds (>= gutter). If the flip would also overflow, fall back to the original right/below placement (the popover is then allowed to overflow the viewport edge — better than placing it far from the cursor).
All popovers in this plugin are triggered by hover, so the cursor position is always recorded at trigger time and passed in; the target element's rectangle is intentionally NOT part of the computation.