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

  • readonly

    config : Object

    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.

  • readonly

    left : Number

    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.

  • readonly

    name : String

    Position name.

  • readonly

    top : Number

    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.

  • private

    _absoluteRect : Rect

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

  • private readonly

    _limiterIntersectionArea : Number

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

  • private

    _rect : Rect

    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.

  • private readonly

    _viewportIntersectionArea : Number

    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".