Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/third_party/closure/goog/positioning/menuanchoredposition.js
4113 views
1
/**
2
* @license
3
* Copyright The Closure Library Authors.
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
/**
8
* @fileoverview Anchored viewport positioning class with both adjust and
9
* resize options for the popup.
10
*/
11
12
goog.provide('goog.positioning.MenuAnchoredPosition');
13
14
goog.require('goog.positioning.AnchoredViewportPosition');
15
goog.require('goog.positioning.Overflow');
16
goog.requireType('goog.positioning.Corner');
17
18
19
20
/**
21
* Encapsulates a popup position where the popup is anchored at a corner of
22
* an element. The positioning behavior changes based on the values of
23
* opt_adjust and opt_resize.
24
*
25
* When using this positioning object it's recommended that the movable element
26
* be absolutely positioned.
27
*
28
* @param {Element} anchorElement Element the movable element should be
29
* anchored against.
30
* @param {goog.positioning.Corner} corner Corner of anchored element the
31
* movable element should be positioned at.
32
* @param {boolean=} opt_adjust Whether the positioning should be adjusted until
33
* the element fits inside the viewport even if that means that the anchored
34
* corners are ignored.
35
* @param {boolean=} opt_resize Whether the positioning should be adjusted until
36
* the element fits inside the viewport on the X axis and its height is
37
* resized so if fits in the viewport. This take precedence over opt_adjust.
38
* @constructor
39
* @extends {goog.positioning.AnchoredViewportPosition}
40
*/
41
goog.positioning.MenuAnchoredPosition = function(
42
anchorElement, corner, opt_adjust, opt_resize) {
43
'use strict';
44
goog.positioning.AnchoredViewportPosition.call(
45
this, anchorElement, corner, opt_adjust || opt_resize);
46
47
if (opt_adjust || opt_resize) {
48
var overflowX = goog.positioning.Overflow.ADJUST_X_EXCEPT_OFFSCREEN;
49
var overflowY = opt_resize ?
50
goog.positioning.Overflow.RESIZE_HEIGHT :
51
goog.positioning.Overflow.ADJUST_Y_EXCEPT_OFFSCREEN;
52
this.setLastResortOverflow(overflowX | overflowY);
53
}
54
};
55
goog.inherits(
56
goog.positioning.MenuAnchoredPosition,
57
goog.positioning.AnchoredViewportPosition);
58
59