Trilium Frontend API
    Preparing search index...

    Type Alias PositioningFunction

    PositioningFunction: (
        elementRect: Rect,
        targetRect: Rect,
        viewportRect: Rect,
        limiterRect?: Rect,
    ) => DomPositioningFunctionResult | null

    A positioning function which, based on positioned element and target module:utils/dom/rect~Rect Rects, returns rect coordinates representing the geometrical relation between them. Used by the module:utils/dom/position~getOptimalPosition helper.

    // This simple position will place the element directly under the target, in the middle:
    //
    // [ Target ]
    // +-----------------+
    // | Element |
    // +-----------------+
    //
    const position = ( targetRect, elementRect, [ viewportRect ] ) => ( {
    top: targetRect.bottom,
    left: targetRect.left + targetRect.width / 2 - elementRect.width / 2,
    name: 'bottomMiddle',

    // Note: The config is optional.
    config: {
    zIndex: '999'
    }
    } );

    Type Declaration

      • (
            elementRect: Rect,
            targetRect: Rect,
            viewportRect: Rect,
            limiterRect?: Rect,
        ): DomPositioningFunctionResult | null
      • Parameters

        • elementRect: Rect

          The rect of the element to be positioned.

        • targetRect: Rect

          The rect of the target the element (its rect) is relatively positioned to.

        • viewportRect: Rect

          The rect of the visual browser viewport.

        • OptionallimiterRect: Rect

        Returns DomPositioningFunctionResult | null

        When the function returns null, it will not be considered by module:utils/dom/position~getOptimalPosition.