The goog.positioning Namespace

The goog.positioning.AbsolutePosition Class

Encapsulates a popup position where the popup absolutely positioned by setting the left/top style elements directly to the specified values. The position is generally relative to the element's offsetParent. Normally, this is the document body, but can be another element if the popup element is scoped by an element with relative position. … more

The goog.positioning.AbstractPosition Class

Abstract position object. Encapsulates position and overflow handling. … more

The goog.positioning.AnchoredPosition Class

Encapsulates a popup position where the popup is anchored at a corner of an element. When using AnchoredPosition, it is recommended that the popup element specified in the Popup constructor or Popup.setElement be absolutely positioned. … more

The goog.positioning.AnchoredViewportPosition Class

Encapsulates a popup position where the popup is anchored at a corner of an element. The corners are swapped if dictated by the viewport. For instance if a popup is anchored with its top left corner to the bottom left corner of the anchor the popup is either displayed below the anchor (as specified) or above it if there's not enough room to display it below. When using this positioning object it's recommended that the movable element be absolutely positioned. … more

The goog.positioning.ClientPosition Class

Encapsulates a popup position where the popup is positioned relative to the window (client) coordinates. This calculates the correct position to use even if the element is relatively positioned to some other element. This is for trying to position an element at the spot of the mouse cursor in a MOUSEMOVE event. Just use the event.clientX and event.clientY as the parameters. … more

The goog.positioning.Corner Enum

Enum for representing an element corner for positioning the popup. The START constants map to LEFT if element directionality is left to right and RIGHT if the directionality is right to left. Likewise END maps to RIGHT or LEFT depending on the directionality. … more

The goog.positioning.CornerBit Enum

Enum for bits in the {@see goog.positioning.Corner) bitmap. … more

Encapsulates a popup position where the popup is anchored at a corner of an element. The positioning behavior changes based on the values of opt_adjust and opt_resize. When using this positioning object it's recommended that the movable element be absolutely positioned. … more

The goog.positioning.Overflow Enum

Enum for representing position handling in cases where the element would be positioned outside the viewport. … more

The goog.positioning.OverflowStatus Enum

Enum for representing the outcome of a positioning call. … more

The goog.positioning.ViewportClientPosition Class

Encapsulates a popup position where the popup is positioned relative to the window (client) coordinates, and made to stay within the viewport. … more

The goog.positioning.ViewportPosition Class

Encapsulates a popup position where the popup is positioned according to coordinates relative to the element's viewport (page). This calculates the correct position to use even if the element is relatively positioned to some other element. … more

.clientPositionTest

.flipCorner(corner)

Returns the corner opposite the given one horizontally and vertically.

corner {goog.positioning.Corner}
The popup corner used to flip.
returns {goog.positioning.Corner}
The opposite corner horizontally and vertically.

.flipCornerHorizontal(corner)

Returns the corner opposite the given one horizontally.

corner {goog.positioning.Corner}
The popup corner used to flip.
returns {goog.positioning.Corner}
The opposite corner horizontally.

.flipCornerVertical(corner)

Returns the corner opposite the given one vertically.

corner {goog.positioning.Corner}
The popup corner used to flip.
returns {goog.positioning.Corner}
The opposite corner vertically.

.getEffectiveCorner(element, corner)

Returns an absolute corner (top/bottom left/right) given an absolute or relative (top/bottom start/end) corner and the direction of an element. Absolute corners remain unchanged.

element {Element}
DOM element to test for RTL direction.
corner {goog.positioning.Corner}
The popup corner used for positioning.
returns {goog.positioning.Corner}
Effective corner.

.getOffsetParentPageOffset(movableElement)

Calculates the page offset of the given element's offsetParent. This value can be used to translate any x- and y-offset relative to the page to an offset relative to the offsetParent, which can then be used directly with as position coordinate for {@code positionWithCoordinate}.

movableElement {!Element}
The element to calculate.
returns {!goog.math.Coordinate}
The page offset, may be (0, 0).

.positionAtAnchor(anchorElement, anchorElementCorner, movableElement, movableElementCorner, opt_offset, opt_margin, opt_overflow, opt_preferredSize, opt_viewport)

Positions a movable element relative to an anchor element. The caller specifies the corners that should touch. This functions then moves the movable element accordingly.

anchorElement {Element}
The element that is the anchor for where the movable element should position itself.
anchorElementCorner {goog.positioning.Corner}
The corner of the anchorElement for positioning the movable element.
movableElement {Element}
The element to move.
movableElementCorner {goog.positioning.Corner}
The corner of the movableElement that that should be positioned adjacent to the anchor element.
opt_offset {goog.math.Coordinate=}
An offset specified in pixels. After the normal positioning algorithm is applied, the offset is then applied. Positive coordinates move the popup closer to the center of the anchor element. Negative coordinates move the popup away from the center of the anchor element.
opt_margin {goog.math.Box=}
A margin specified in pixels. After the normal positioning algorithm is applied and any offset, the margin is then applied. Positive coordinates move the popup away from the spot it was positioned towards its center. Negative coordinates move it towards the spot it was positioned away from its center.
opt_overflow {?number=}
Overflow handling mode. Defaults to IGNORE if not specified. Bitmap, {@see goog.positioning.Overflow}.
opt_preferredSize {goog.math.Size=}
The preferred size of the movableElement.
opt_viewport {goog.math.Box=}
Box object describing the dimensions of the viewport. If not provided, a default one will be calculated by the position of the anchorElement and its moveable parent element.
returns {goog.positioning.OverflowStatus}
Status bitmap, {@see goog.positioning.OverflowStatus}.

.positionAtCoordinate(absolutePos, movableElement, movableElementCorner, opt_margin, opt_viewport, opt_overflow, opt_preferredSize)

Positions the specified corner of the movable element at the specified coordinate.

absolutePos {goog.math.Coordinate}
The coordinate to position the element at.
movableElement {Element}
The element to be positioned.
movableElementCorner {goog.positioning.Corner}
The corner of the movableElement that that should be positioned.
opt_margin {goog.math.Box=}
A margin specified in pixels. After the normal positioning algorithm is applied and any offset, the margin is then applied. Positive coordinates move the popup away from the spot it was positioned towards its center. Negative coordinates move it towards the spot it was positioned away from its center.
opt_viewport {goog.math.Box=}
Box object describing the dimensions of the viewport. Required if opt_overflow is specified.
opt_overflow {?number=}
Overflow handling mode. Defaults to IGNORE if not specified, {@see goog.positioning.Overflow}.
opt_preferredSize {goog.math.Size=}
The preferred size of the movableElement. Defaults to the current size.
returns {goog.positioning.OverflowStatus}
Status bitmap.