PopupPositionProvider

Interface

Common
interface PopupPositionProvider

Calculates the position of a Popup on screen.

Functions

fun calculatePosition(
        anchorBounds: IntRect,
        windowSize: IntSize,
        layoutDirection: LayoutDirection,
        popupContentSize: IntSize,
    ): IntOffset

Calculates the position of a Popup on screen.

The window size is useful in cases where the popup is meant to be positioned next to its anchor instead of inside of it. The size can be used to calculate available space around the parent to find a spot with enough clearance (e.g. when implementing a dropdown). Note that positioning the popup outside of the window bounds might prevent it from being visible.

Parameters

anchorBoundsThe window relative bounds of the layout which this popup is anchored to.
windowSizeThe size of the window containing the anchor layout.
layoutDirectionThe layout direction of the anchor layout.
popupContentSizeThe size of the popup's content.

Returns

The window relative position where the popup should be positioned.