From 09d726a5a8d05b3695c6bcebee52293b96c8436b Mon Sep 17 00:00:00 2001
From: Robert Long <robert@robertlong.me>
Date: Tue, 31 Aug 2021 15:39:31 -0700
Subject: [PATCH] Fix zero participant tiles case

---
 src/VideoGrid.jsx | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/VideoGrid.jsx b/src/VideoGrid.jsx
index a49d178..beed909 100644
--- a/src/VideoGrid.jsx
+++ b/src/VideoGrid.jsx
@@ -69,8 +69,10 @@ function getTilePositions(
     participantGridHeight = gridHeight;
   }
 
+  const participantTileCount = tileCount - presenterTileCount;
+
   const participantGridPositions = getSubGridPositions(
-    tileCount - presenterTileCount,
+    participantTileCount,
     participantGridWidth,
     participantGridHeight,
     gap
@@ -84,9 +86,13 @@ function getTilePositions(
     presenterGridHeight = 0;
   } else if (layoutDirection === "vertical") {
     presenterGridWidth = gridWidth;
-    presenterGridHeight = gridHeight - (participantGridBounds.height + gap * 2);
+    presenterGridHeight =
+      gridHeight -
+      (participantGridBounds.height + (participantTileCount ? gap * 2 : 0));
   } else {
-    presenterGridWidth = gridWidth - (participantGridBounds.width + gap * 2);
+    presenterGridWidth =
+      gridWidth -
+      (participantGridBounds.width + (participantTileCount ? gap * 2 : 0));
     presenterGridHeight = gridHeight;
   }