#1009 item.descriptor.popover

This commit is contained in:
Carlos Jimenez Ruiz 2019-04-10 07:20:23 +02:00
parent 26ba8b2463
commit eaad6c6f6e
1 changed files with 6 additions and 3 deletions

View File

@ -118,6 +118,7 @@ export default class Popover extends Component {
*/
relocate() {
if (!(this.parent && this._shown)) return;
let margin = 10;
let style = this.popover.style;
style.width = '';
@ -136,9 +137,8 @@ export default class Popover extends Component {
let height = popoverRect.height;
let width = Math.max(popoverRect.width, parentRect.width);
let top = parentRect.top + parentRect.height + arrowHeight;
let left = parentRect.left + parentRect.width / 2 - width / 2;
let left = Math.max(parentRect.left + parentRect.width / 2 - width / 2, margin);
let margin = 10;
let showTop = top + height + margin > window.innerHeight;
if (showTop)
@ -151,7 +151,10 @@ export default class Popover extends Component {
else
arrowStyle.top = `0`;
arrowStyle.left = `${(parentRect.left - left) + parentRect.width / 2}px`;
let arrowMargin = margin + 10;
let arrowLeft = (parentRect.left - left) + parentRect.width / 2;
arrowLeft = Math.max(Math.min(arrowLeft, width - arrowMargin), arrowMargin);
arrowStyle.left = `${arrowLeft}px`;
style.top = `${top}px`;
style.left = `${left}px`;