From d70c8e23f4fc8ae25f792aa29c8df5952cea2c4f Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Wed, 28 Jan 2026 21:12:34 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=96=B1=EF=B8=8F=20Refine=20scrolling=20be?= =?UTF-8?q?havior=20to=20center=20elements=20within=20their=20container=20?= =?UTF-8?q?instead=20of=20the=20whole=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pokedex.online/src/views/GamemasterExplorer.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/code/websites/pokedex.online/src/views/GamemasterExplorer.vue b/code/websites/pokedex.online/src/views/GamemasterExplorer.vue index cd25954..59bce73 100644 --- a/code/websites/pokedex.online/src/views/GamemasterExplorer.vue +++ b/code/websites/pokedex.online/src/views/GamemasterExplorer.vue @@ -761,8 +761,16 @@ function scrollToResult() { const lineElement = document.querySelector(`[data-line="${lineNumber}"]`); if (lineElement) { - // Element is rendered, scroll it into view - lineElement.scrollIntoView({ behavior: 'smooth', block: 'center' }); + // Scroll only within the container, not the whole page + const container = lineElement.closest('.scroller, .lines-container'); + if (container) { + const containerRect = container.getBoundingClientRect(); + const elementRect = lineElement.getBoundingClientRect(); + + // Calculate scroll position to center element in container + const scrollOffset = elementRect.top - containerRect.top - (containerRect.height / 2) + (elementRect.height / 2); + container.scrollBy({ top: scrollOffset, behavior: 'smooth' }); + } return true; } else if (attempt < 3) { // Virtual scroller may not have rendered yet, try again