@tetacom/ng-components 1.0.20 → 1.0.21
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.
- package/common/util/position-util.d.ts +1 -1
- package/esm2020/common/util/position-util.mjs +13 -4
- package/esm2020/component/dropdown/dropdown-base.mjs +24 -16
- package/fesm2015/tetacom-ng-components.mjs +35 -18
- package/fesm2015/tetacom-ng-components.mjs.map +1 -1
- package/fesm2020/tetacom-ng-components.mjs +35 -18
- package/fesm2020/tetacom-ng-components.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -952,7 +952,12 @@ var VerticalAlign;
|
|
|
952
952
|
})(VerticalAlign || (VerticalAlign = {}));
|
|
953
953
|
|
|
954
954
|
class PositionUtil {
|
|
955
|
-
static getPosition(containerPosition, elementPosition, align, verticalAlign, margin = 0, verticalMargin = 0
|
|
955
|
+
static getPosition(containerPosition, elementPosition, align, verticalAlign, margin = 0, verticalMargin = 0, transformedParentRect = {
|
|
956
|
+
left: 0,
|
|
957
|
+
right: 0,
|
|
958
|
+
top: 0,
|
|
959
|
+
bottom: 0
|
|
960
|
+
}) {
|
|
956
961
|
const rect = {};
|
|
957
962
|
const elementWidth = elementPosition.right - elementPosition.left;
|
|
958
963
|
const elementHeight = elementPosition.bottom - elementPosition.top;
|
|
@@ -988,7 +993,7 @@ class PositionUtil {
|
|
|
988
993
|
}
|
|
989
994
|
}
|
|
990
995
|
if (verticalAlign === VerticalAlign.top) {
|
|
991
|
-
rect.
|
|
996
|
+
rect.top = containerPosition.top - elementHeight - verticalMargin;
|
|
992
997
|
}
|
|
993
998
|
if (verticalAlign === VerticalAlign.bottom) {
|
|
994
999
|
rect.top = containerPosition.bottom + verticalMargin;
|
|
@@ -1007,12 +1012,16 @@ class PositionUtil {
|
|
|
1007
1012
|
if (rect.top < 0) {
|
|
1008
1013
|
rect.top = 0;
|
|
1009
1014
|
}
|
|
1010
|
-
if (verticalAlign === VerticalAlign.bottom) {
|
|
1015
|
+
if (verticalAlign === VerticalAlign.bottom || verticalAlign === VerticalAlign.center) {
|
|
1011
1016
|
rect.maxHeight = window.innerHeight - rect.top;
|
|
1012
1017
|
}
|
|
1013
1018
|
if (verticalAlign === VerticalAlign.top) {
|
|
1014
1019
|
rect.maxHeight = containerPosition.top;
|
|
1015
1020
|
}
|
|
1021
|
+
rect.left = rect.left - transformedParentRect.left;
|
|
1022
|
+
rect.right = rect.right - transformedParentRect.left;
|
|
1023
|
+
rect.top = rect.top - transformedParentRect.top;
|
|
1024
|
+
rect.bottom = rect.bottom ? rect.bottom - transformedParentRect.bottom : rect.bottom;
|
|
1016
1025
|
return rect;
|
|
1017
1026
|
}
|
|
1018
1027
|
static setElementPosition(element, rect) {
|
|
@@ -1190,23 +1199,31 @@ class DropdownBase {
|
|
|
1190
1199
|
this.setPosition(this._head.nativeElement, this._body);
|
|
1191
1200
|
}
|
|
1192
1201
|
setPosition(container, target) {
|
|
1193
|
-
const
|
|
1202
|
+
const containerPosition = container.getBoundingClientRect();
|
|
1203
|
+
const targetPosition = target.getBoundingClientRect();
|
|
1194
1204
|
const rect = {
|
|
1195
|
-
bottom:
|
|
1196
|
-
top:
|
|
1197
|
-
left:
|
|
1198
|
-
right:
|
|
1205
|
+
bottom: containerPosition.bottom,
|
|
1206
|
+
top: containerPosition.top,
|
|
1207
|
+
left: containerPosition.left,
|
|
1208
|
+
right: containerPosition.right,
|
|
1209
|
+
};
|
|
1210
|
+
const targetRect = {
|
|
1211
|
+
bottom: targetPosition.bottom,
|
|
1212
|
+
top: targetPosition.top,
|
|
1213
|
+
left: targetPosition.left,
|
|
1214
|
+
right: targetPosition.right,
|
|
1199
1215
|
};
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1216
|
+
const targetTransformedParent = DomUtil.findTransformedParent(target);
|
|
1217
|
+
let parentPosition = {
|
|
1218
|
+
left: 0,
|
|
1219
|
+
right: 0,
|
|
1220
|
+
top: 0,
|
|
1221
|
+
bottom: 0
|
|
1222
|
+
};
|
|
1223
|
+
if (targetTransformedParent) {
|
|
1224
|
+
parentPosition = targetTransformedParent.getBoundingClientRect();
|
|
1225
|
+
}
|
|
1226
|
+
const position = PositionUtil.getPosition(rect, targetRect, this.align, this.verticalAlign, 0, 0, parentPosition);
|
|
1210
1227
|
PositionUtil.setElementPosition(target, position);
|
|
1211
1228
|
}
|
|
1212
1229
|
}
|