Skip to content

Commit 1c6c77d

Browse files
committed
fix: drag markers not getting positioned correctly when webpage has fixed positioned elements
1 parent bca6ddb commit 1c6c77d

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -693,13 +693,8 @@ function RemoteFunctions(config) {
693693
marker.className = indicatorType === "vertical" ? DROP_MARKER_VERTICAL_CLASSNAME : DROP_MARKER_CLASSNAME;
694694
}
695695

696-
// position the marker at the top or bottom of the element
697696
let rect = element.getBoundingClientRect();
698-
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
699-
let scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
700-
701-
// base marker styling
702-
marker.style.position = "absolute";
697+
marker.style.position = "fixed";
703698
marker.style.zIndex = "2147483646";
704699
marker.style.borderRadius = "2px";
705700
marker.style.pointerEvents = "none";
@@ -708,8 +703,8 @@ function RemoteFunctions(config) {
708703
// inside marker - outline around the element
709704
marker.style.border = "1px dashed #4285F4";
710705
marker.style.backgroundColor = "rgba(66, 133, 244, 0.05)";
711-
marker.style.left = rect.left + scrollLeft + "px";
712-
marker.style.top = rect.top + scrollTop + "px";
706+
marker.style.left = rect.left + "px";
707+
marker.style.top = rect.top + "px";
713708
marker.style.width = rect.width + "px";
714709
marker.style.height = rect.height + "px";
715710
marker.style.animation = "insideMarkerPulse 1s ease-in-out infinite alternate";
@@ -723,23 +718,23 @@ function RemoteFunctions(config) {
723718
// Vertical marker (for flex row containers)
724719
marker.style.width = "2px";
725720
marker.style.height = rect.height + "px";
726-
marker.style.top = rect.top + scrollTop + "px";
721+
marker.style.top = rect.top + "px";
727722

728723
if (dropZone === "after") {
729-
marker.style.left = rect.right + scrollLeft + 3 + "px";
724+
marker.style.left = rect.right + 3 + "px";
730725
} else {
731-
marker.style.left = rect.left + scrollLeft - 5 + "px";
726+
marker.style.left = rect.left - 5 + "px";
732727
}
733728
} else {
734729
// Horizontal marker (for block/grid containers)
735730
marker.style.width = rect.width + "px";
736731
marker.style.height = "2px";
737-
marker.style.left = rect.left + scrollLeft + "px";
732+
marker.style.left = rect.left + "px";
738733

739734
if (dropZone === "after") {
740-
marker.style.top = rect.bottom + scrollTop + 3 + "px";
735+
marker.style.top = rect.bottom + 3 + "px";
741736
} else {
742-
marker.style.top = rect.top + scrollTop - 5 + "px";
737+
marker.style.top = rect.top - 5 + "px";
743738
}
744739
}
745740
}

0 commit comments

Comments
 (0)