Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/dev This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-04-10 09:34:17 +02:00
commit a577218f5d
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`;