Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/third_party/closure/goog/positioning/anchoredposition.js
4122 views
1
/**
2
* @license
3
* Copyright The Closure Library Authors.
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
/**
8
* @fileoverview Client positioning class.
9
*/
10
11
goog.provide('goog.positioning.AnchoredPosition');
12
13
goog.require('goog.positioning');
14
goog.require('goog.positioning.AbstractPosition');
15
goog.requireType('goog.math.Box');
16
goog.requireType('goog.math.Size');
17
18
19
20
/**
21
* Encapsulates a popup position where the popup is anchored at a corner of
22
* an element.
23
*
24
* When using AnchoredPosition, it is recommended that the popup element
25
* specified in the Popup constructor or Popup.setElement be absolutely
26
* 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 {number=} opt_overflow Overflow handling mode. Defaults to IGNORE if
33
* not specified. Bitmap, {@see goog.positioning.Overflow}.
34
* @constructor
35
* @extends {goog.positioning.AbstractPosition}
36
*/
37
goog.positioning.AnchoredPosition = function(
38
anchorElement, corner, opt_overflow) {
39
'use strict';
40
/**
41
* Element the movable element should be anchored against.
42
* @type {Element}
43
*/
44
this.element = anchorElement;
45
46
/**
47
* Corner of anchored element the movable element should be positioned at.
48
* @type {goog.positioning.Corner}
49
*/
50
this.corner = corner;
51
52
/**
53
* Overflow handling mode. Defaults to IGNORE if not specified.
54
* Bitmap, {@see goog.positioning.Overflow}.
55
* @type {number|undefined}
56
* @private
57
*/
58
this.overflow_ = opt_overflow;
59
};
60
goog.inherits(
61
goog.positioning.AnchoredPosition, goog.positioning.AbstractPosition);
62
63
64
/**
65
* Repositions the movable element.
66
*
67
* @param {Element} movableElement Element to position.
68
* @param {goog.positioning.Corner} movableCorner Corner of the movable element
69
* that should be positioned adjacent to the anchored element.
70
* @param {goog.math.Box=} opt_margin A margin specifin pixels.
71
* @param {goog.math.Size=} opt_preferredSize PreferredSize of the
72
* movableElement (unused in this class).
73
* @override
74
*/
75
goog.positioning.AnchoredPosition.prototype.reposition = function(
76
movableElement, movableCorner, opt_margin, opt_preferredSize) {
77
'use strict';
78
goog.positioning.positionAtAnchor(
79
this.element, this.corner, movableElement, movableCorner, undefined,
80
opt_margin, this.overflow_);
81
};
82
83