Path: blob/trunk/third_party/closure/goog/positioning/menuanchoredposition.js
4113 views
/**1* @license2* Copyright The Closure Library Authors.3* SPDX-License-Identifier: Apache-2.04*/56/**7* @fileoverview Anchored viewport positioning class with both adjust and8* resize options for the popup.9*/1011goog.provide('goog.positioning.MenuAnchoredPosition');1213goog.require('goog.positioning.AnchoredViewportPosition');14goog.require('goog.positioning.Overflow');15goog.requireType('goog.positioning.Corner');16171819/**20* Encapsulates a popup position where the popup is anchored at a corner of21* an element. The positioning behavior changes based on the values of22* opt_adjust and opt_resize.23*24* When using this positioning object it's recommended that the movable element25* be absolutely positioned.26*27* @param {Element} anchorElement Element the movable element should be28* anchored against.29* @param {goog.positioning.Corner} corner Corner of anchored element the30* movable element should be positioned at.31* @param {boolean=} opt_adjust Whether the positioning should be adjusted until32* the element fits inside the viewport even if that means that the anchored33* corners are ignored.34* @param {boolean=} opt_resize Whether the positioning should be adjusted until35* the element fits inside the viewport on the X axis and its height is36* resized so if fits in the viewport. This take precedence over opt_adjust.37* @constructor38* @extends {goog.positioning.AnchoredViewportPosition}39*/40goog.positioning.MenuAnchoredPosition = function(41anchorElement, corner, opt_adjust, opt_resize) {42'use strict';43goog.positioning.AnchoredViewportPosition.call(44this, anchorElement, corner, opt_adjust || opt_resize);4546if (opt_adjust || opt_resize) {47var overflowX = goog.positioning.Overflow.ADJUST_X_EXCEPT_OFFSCREEN;48var overflowY = opt_resize ?49goog.positioning.Overflow.RESIZE_HEIGHT :50goog.positioning.Overflow.ADJUST_Y_EXCEPT_OFFSCREEN;51this.setLastResortOverflow(overflowX | overflowY);52}53};54goog.inherits(55goog.positioning.MenuAnchoredPosition,56goog.positioning.AnchoredViewportPosition);575859