Skip to content

Commit c06b02b

Browse files
committed
fix: more options box positioning when live preview is scrolled
1 parent ea7338f commit c06b02b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,7 @@ function RemoteFunctions(config) {
265265
// Remove existing more options box if any
266266
this.remove();
267267

268-
// compute the position on screen (this gives us the left and the top offset)
269-
var offset = _screenOffset(this.element);
270-
// we need to fetch the height & width of the element to place the box at the correct position
271-
var elementSize = this.element.getBoundingClientRect();
268+
let elemBounds = this.element.getBoundingClientRect();
272269

273270
// for styling the svg's
274271
if (!document.getElementById("node-more-options-style")) {
@@ -288,8 +285,11 @@ function RemoteFunctions(config) {
288285
this.body = window.document.createElement("div");
289286
this.body.style.setProperty("z-index", 2147483647);
290287
this.body.style.setProperty("position", "fixed");
291-
this.body.style.setProperty("left", (offset.left + (elementSize.width - 40)) + "px");
292-
this.body.style.setProperty("top", (offset.top - 30 < 0 ? offset.top + this.element.offsetHeight + 5 : offset.top - 30) + "px");
288+
this.body.style.setProperty("left", elemBounds.left + (elemBounds.width - 40) + "px");
289+
this.body.style.setProperty(
290+
"top",
291+
(elemBounds.top - 30 < 0 ? elemBounds.top + elemBounds.offsetHeight + 5 : elemBounds.top - 30) + "px"
292+
);
293293
this.body.style.setProperty("font-size", "12px");
294294
this.body.style.setProperty("font-family", "Arial, sans-serif");
295295

0 commit comments

Comments
 (0)