Skip to content

Commit f691e5a

Browse files
committed
fix: box now moves along with the selected element when scrolled
1 parent 2a182eb commit f691e5a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,13 @@ function RemoteFunctions(config) {
323323

324324
// the box width and the positions where it should be placed
325325
const boxWidth = 82;
326-
const leftPos = (elemBounds.right - boxWidth);
327-
const topPos = (elemBounds.top - 30 < 0 ? elemBounds.top + elemBounds.height + 5 : elemBounds.top - 30);
326+
const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
327+
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
328+
329+
const leftPos = elemBounds.right - boxWidth + scrollLeft;
330+
const topPos = (elemBounds.top - 30 < 0
331+
? elemBounds.top + elemBounds.height + 5
332+
: elemBounds.top - 30) + scrollTop;
328333

329334
// the icons that is displayed in the box
330335
const ICONS = {
@@ -371,7 +376,7 @@ function RemoteFunctions(config) {
371376
font-size: 12px;
372377
font-family: Arial, sans-serif;
373378
z-index: 2147483647;
374-
position: fixed;
379+
position: absolute;
375380
left: ${leftPos}px;
376381
top: ${topPos}px;
377382
width: ${boxWidth}px;

0 commit comments

Comments
 (0)