Class

Position (utils/dom)

@ckeditor/ckeditor5-utils/src/dom/position

class

A position class which instances are created and used by the getOptimalPosition helper.

top and left properties of the position instance translate directly to the top and left properties in CSS "position: absolute coordinate system". If set on the positioned element in DOM, they will make it display it in the right place in the viewport.

Filtering

Properties

  • config : Object

    readonly

    Additional position configuration, as passed from the positioning function.

    This object can be use, for instance, to pass through presentation options used by the consumer of the getOptimalPosition helper.

  • left : Number

    readonly

    The left value in pixels in the CSS position: absolute coordinate system. Set it on the positioned element in DOM to move it to the position.

  • name : String

    readonly

    Position name.

  • top : Number

    readonly

    The top value in pixels in the CSS position: absolute coordinate system. Set it on the positioned element in DOM to move it to the position.

  • _absoluteRect : Rect

    private

    An already absolutely positioned element rect. See (_rect).

  • _limiterIntersectionArea : Number

    private readonly

    An intersection area between positioned element and limiter within viewport constraints.

  • _rect : Rect

    private

    An already positioned element rect. A clone of the element rect passed to the constructor but placed in the viewport according to the positioning function.

  • _viewportIntersectionArea : Number

    private readonly

    An intersection area between positioned element and viewport.

Methods

  • constructor( [ positioningFunction ], [ options ] = { options.elementRect, options.targetRect, options.viewportRect, [options.positionedElementAncestor] } )

    Creates an instance of the Position class.

    Parameters

    [ positioningFunction ] : positioningFunction

    function The function that defines the expected coordinates the positioned element should move to.

    [ options ] : Object

    options object.

    Properties
    options.elementRect : Rect

    The positioned element rect.

    options.targetRect : Rect

    The target element rect.

    options.viewportRect : Rect

    The viewport rect.

    [ options.positionedElementAncestor ] : HTMLElement | null

    Nearest element ancestor element which CSS position is not "static".