From 03978631ebd1e61abd13dd7a53bdb400c3d0f059 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 13 Sep 2024 21:00:41 +0200 Subject: [PATCH] Fix: scroll horizontal images into view --- src/Utils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Utils.ts b/src/Utils.ts index 99674d926..8203014a7 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -1452,6 +1452,7 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be if (!element) { return } + console.log("Scrolling into view:", element) // Is the element completely in the view? const parentRect = Utils.findParentWithScrolling(element)?.getBoundingClientRect() if (!parentRect) { @@ -1462,7 +1463,9 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be // Check if the element is within the vertical bounds of the parent element const topIsVisible = elementRect.top >= parentRect.top const bottomIsVisible = elementRect.bottom <= parentRect.bottom - const inView = topIsVisible && bottomIsVisible + const leftIsVisible = elementRect.left >= parentRect.left + const rightIsVisible = elementRect.right <= parentRect.right + const inView = topIsVisible && bottomIsVisible && leftIsVisible && rightIsVisible if (inView) { return }