Skip to content

Commit bfa87a3

Browse files
committed
if bottom-middle-aligned goes off the right side
1 parent e1a039f commit bfa87a3

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

intro.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,12 @@
520520
tooltipOffset = _getOffset(tooltipLayer);
521521

522522
arrowLayer.className = 'introjs-arrow top-middle';
523-
tooltipLayer.style.left = (targetElementOffset.width / 2 - tooltipOffset.width / 2) + 'px';
523+
var tooltipLayerStyleLeft = targetElementOffset.width / 2 - tooltipOffset.width / 2;
524+
// off the right side of the window
525+
if (targetElementOffset.left + tooltipLayerStyleLeft + tooltipOffset.width > windowSize.width)
526+
tooltipLayer.style.left = (windowSize.width - tooltipOffset.width - targetElementOffset.left) + 'px';
527+
else
528+
tooltipLayer.style.left = tooltipLayerStyleLeft + 'px';
524529
tooltipLayer.style.top = (targetElementOffset.height + 20) + 'px';
525530
break;
526531
case 'bottom-left-aligned':

0 commit comments

Comments
 (0)