GraphTooltip: added boundaries so we never render tooltip outside window. (#20874)

This commit is contained in:
Marcus Andersson 2019-12-04 18:08:50 +01:00 committed by Torkel Ödegaard
parent ad33d95dd3
commit 5f72bfe6e7

View File

@ -42,8 +42,11 @@ $.fn.place_tt = (() => {
width = $tooltip.outerWidth(true);
height = $tooltip.outerHeight(true);
$tooltip.css('left', x + opts.offset + width > $win.width() ? x - opts.offset - width : x + opts.offset);
$tooltip.css('top', y + opts.offset + height > $win.height() ? y - opts.offset - height : y + opts.offset);
const left = x + opts.offset + width > $win.width() ? x - opts.offset - width : x + opts.offset;
const top = y + opts.offset + height > $win.height() ? y - opts.offset - height : y + opts.offset;
$tooltip.css('left', left > 0 ? left : 0);
$tooltip.css('top', top > 0 ? top : 0);
});
};
})();