@singularsystems/neo-core 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -174,7 +174,8 @@ var DatePicker = /** @class */ (function () {
|
|
|
174
174
|
};
|
|
175
175
|
DatePicker.prototype.positionPopup = function (fromBottom) {
|
|
176
176
|
if (this.popup) {
|
|
177
|
-
|
|
177
|
+
var textAlign = this.options.popupAlignRight ? undefined : window.getComputedStyle(this.input).textAlign;
|
|
178
|
+
PositionHelper.checkScreenBounds(this.container, this.popup, fromBottom, this.options.popupAlignRight, textAlign);
|
|
178
179
|
}
|
|
179
180
|
};
|
|
180
181
|
/**
|
|
@@ -5,6 +5,7 @@ export default class PositionHelper {
|
|
|
5
5
|
* @param popup The element which pops up from the anchor.
|
|
6
6
|
* @param fromBottom True if the popups bottom style property must be set. Set to false if there are buttons at the top of the popup and the popups height may change.
|
|
7
7
|
* @param alignRight True if the popup must be aligned to the anchors right position.
|
|
8
|
+
* @param hAlign Horizontal alignment of the popup edge relative to the anchor edge. Overrides alignRight
|
|
8
9
|
*/
|
|
9
|
-
static checkScreenBounds(anchor: HTMLElement, popup: HTMLElement, fromBottom?: boolean, alignRight?: boolean): void;
|
|
10
|
+
static checkScreenBounds(anchor: HTMLElement, popup: HTMLElement, fromBottom?: boolean, alignRight?: boolean, hAlign?: "left" | "center" | "right"): void;
|
|
10
11
|
}
|
|
@@ -7,12 +7,14 @@ var PositionHelper = /** @class */ (function () {
|
|
|
7
7
|
* @param popup The element which pops up from the anchor.
|
|
8
8
|
* @param fromBottom True if the popups bottom style property must be set. Set to false if there are buttons at the top of the popup and the popups height may change.
|
|
9
9
|
* @param alignRight True if the popup must be aligned to the anchors right position.
|
|
10
|
+
* @param hAlign Horizontal alignment of the popup edge relative to the anchor edge. Overrides alignRight
|
|
10
11
|
*/
|
|
11
|
-
PositionHelper.checkScreenBounds = function (anchor, popup, fromBottom, alignRight) {
|
|
12
|
+
PositionHelper.checkScreenBounds = function (anchor, popup, fromBottom, alignRight, hAlign) {
|
|
12
13
|
if (fromBottom === void 0) { fromBottom = true; }
|
|
13
14
|
if (alignRight === void 0) { alignRight = false; }
|
|
14
15
|
var popupHeight = popup.offsetHeight;
|
|
15
16
|
var containerScreenRect = anchor.getBoundingClientRect();
|
|
17
|
+
// Vertical
|
|
16
18
|
if (containerScreenRect.bottom + anchor.offsetHeight + popupHeight > window.innerHeight - 20 && containerScreenRect.top > popupHeight) {
|
|
17
19
|
if (fromBottom) {
|
|
18
20
|
popup.style.top = "auto";
|
|
@@ -27,15 +29,30 @@ var PositionHelper = /** @class */ (function () {
|
|
|
27
29
|
popup.style.top = "100%";
|
|
28
30
|
popup.style.bottom = "auto";
|
|
29
31
|
}
|
|
32
|
+
// Horizontal
|
|
30
33
|
var popupWidth = popup.offsetWidth;
|
|
31
|
-
if (
|
|
32
|
-
|
|
34
|
+
if (!hAlign) {
|
|
35
|
+
hAlign = alignRight ? "right" : "left";
|
|
36
|
+
}
|
|
37
|
+
var isRightAligned = hAlign === "right" && (containerScreenRect.right - popupWidth >= 0);
|
|
38
|
+
if (isRightAligned) {
|
|
33
39
|
popup.style.left = "auto";
|
|
34
40
|
popup.style.right = "0";
|
|
35
41
|
}
|
|
36
42
|
else {
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
var left = 0;
|
|
44
|
+
if (hAlign === "center") {
|
|
45
|
+
left = (containerScreenRect.width - popup.offsetWidth) / 2;
|
|
46
|
+
}
|
|
47
|
+
var leftCheck = containerScreenRect.left + left;
|
|
48
|
+
if (leftCheck < 0) {
|
|
49
|
+
left -= leftCheck;
|
|
50
|
+
}
|
|
51
|
+
else if (leftCheck + popup.offsetWidth > window.innerWidth - 20) {
|
|
52
|
+
left -= (leftCheck + popup.offsetWidth) - (window.innerWidth - 20);
|
|
53
|
+
}
|
|
54
|
+
popup.style.left = left + "px";
|
|
55
|
+
popup.style.right = "";
|
|
39
56
|
}
|
|
40
57
|
};
|
|
41
58
|
return PositionHelper;
|