Skip to content

Commit a47562f

Browse files
committed
fix: make sure the info box never gets out of bounds
1 parent 0ddeb9b commit a47562f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,11 +730,22 @@ function RemoteFunctions(config) {
730730

731731
if (overlap) {
732732
topPos = offset.top + 2;
733-
leftPos = offset.left + elemBounds.width + 6;
733+
leftPos = offset.left + elemBounds.width + 6; // positioning at the right side
734734

735735
// Check if overlap position would go off the right of the viewport
736736
if (leftPos + boxDimensions.width > window.innerWidth) {
737-
leftPos = offset.left - boxDimensions.width - 6;
737+
leftPos = offset.left - boxDimensions.width - 6; // positioning at the left side
738+
739+
if (leftPos < 0) { // if left positioning not perfect, position at bottom
740+
topPos = offset.top + elemBounds.height + 6;
741+
leftPos = offset.left;
742+
743+
// if bottom position not perfect, move at top above the more options box
744+
if (elemBounds.bottom + 6 + boxDimensions.height > window.innerHeight) {
745+
topPos = offset.top - boxDimensions.height - 34; // 34 is for moreOptions box height
746+
leftPos = offset.left;
747+
}
748+
}
738749
}
739750
} else {
740751
topPos = offset.top - boxDimensions.height - 6; // 6 for just some little space to breathe

0 commit comments

Comments
 (0)