From 118804926f5b98eb2e0842f32ecfde0f188c155a Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 26 May 2025 09:02:12 -0400 Subject: [PATCH] Changed view for more combatants. --- src/App.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/App.js b/src/App.js index 747b1e5..b470e7d 100644 --- a/src/App.js +++ b/src/App.js @@ -234,7 +234,7 @@ function App() { {!isAuthReady && !error &&

Authenticating...

} ); @@ -932,7 +932,7 @@ function DisplayView() { const [encounterError, setEncounterError] = useState(null); const [campaignBackgroundUrl, setCampaignBackgroundUrl] = useState(''); const [isPlayerDisplayActive, setIsPlayerDisplayActive] = useState(false); - const currentTurnRef = useRef(null); // Ref for the current turn participant's element + const currentTurnRef = useRef(null); useEffect(() => { if (!db) { @@ -994,7 +994,6 @@ function DisplayView() { }; }, [activeDisplayData, isLoadingActiveDisplay]); - // Scroll to current turn participant useEffect(() => { if (currentTurnRef.current) { currentTurnRef.current.scrollIntoView({ @@ -1002,7 +1001,7 @@ function DisplayView() { block: 'center', }); } - }, [activeEncounterData?.currentTurnParticipantId]); // Rerun when current turn changes + }, [activeEncounterData?.currentTurnParticipantId]); if (isLoadingActiveDisplay || (isPlayerDisplayActive && isLoadingEncounter)) { return
Loading Player Display...
; @@ -1043,8 +1042,8 @@ function DisplayView() { } let participantsToRender = allOrderedActiveParticipants; - const FOCUSED_VIEW_THRESHOLD = 7; - const ITEMS_AROUND_CURRENT = 2; // Show 2 before and 2 after current = 5 total in focused view + const FOCUSED_VIEW_THRESHOLD = 7; // When to switch to focused view + const ITEMS_AROUND_CURRENT = 3; // Show 3 before and 3 after current = 7 total in focused view let inFocusedView = false; if (isStarted && allOrderedActiveParticipants.length >= FOCUSED_VIEW_THRESHOLD) { @@ -1054,12 +1053,12 @@ function DisplayView() { const focusedList = []; for (let i = -ITEMS_AROUND_CURRENT; i <= ITEMS_AROUND_CURRENT; i++) { const listLength = allOrderedActiveParticipants.length; + // Ensure the index wraps around correctly for the circular list effect const actualIndex = (currentIndex + i + listLength) % listLength; focusedList.push(allOrderedActiveParticipants[actualIndex]); } participantsToRender = focusedList; } else { - // Fallback if current turn ID not found, show first few (should not happen ideally) participantsToRender = allOrderedActiveParticipants.slice(0, ITEMS_AROUND_CURRENT * 2 + 1); } } @@ -1087,12 +1086,11 @@ function DisplayView() { {!isStarted && (!participants || participants.length === 0) &&

No participants.

} {participantsToRender.length === 0 && isStarted &&

No active participants.

} - {/* Container for participant list - make it scrollable if focused view is not enough */} -
+
{/* Widened and adjusted maxHeight */} {participantsToRender.map(p => (