popup uses document rect to determine relative position of label

This commit is contained in:
NikolaBorislavovHristov 2019-01-21 16:15:23 +02:00
parent b25d6e3b52
commit 271d113ef1

View file

@ -108,15 +108,15 @@ class Popup extends Component {
this.labelBorderLeftRef.current.removeAttribute('style');
const menuDirections = {};
const bodyRect = document.body.getBoundingClientRect();
const documentRect = document.documentElement.getBoundingClientRect();
const labelRect = this.labelRef.current.getBoundingClientRect();
const menuChildredRect = this.menuChildrenRef.current.getBoundingClientRect();
const borderSize = parseFloat(window.getComputedStyle(this.hiddenBorderRef.current).getPropertyValue('border-top-width'));
const labelPosition = {
left: labelRect.x - bodyRect.x,
top: labelRect.y - bodyRect.y,
right: (bodyRect.width + bodyRect.x) - (labelRect.x + labelRect.width),
bottom: (bodyRect.height + bodyRect.y) - (labelRect.y + labelRect.height)
left: labelRect.x - documentRect.x,
top: labelRect.y - documentRect.y,
right: (documentRect.width + documentRect.x) - (labelRect.x + labelRect.width),
bottom: (documentRect.height + documentRect.y) - (labelRect.y + labelRect.height)
};
if (menuChildredRect.height <= labelPosition.bottom) {