App: Use simpler way to split windows

This commit is contained in:
Leon Grünewald 2024-07-30 01:02:36 +02:00
parent 136a6a7f90
commit 89339aa5ce

View file

@ -11,15 +11,24 @@
onMount(() => { onMount(() => {
streams = new URLSearchParams(window.location.search).getAll("streams"); streams = new URLSearchParams(window.location.search).getAll("streams");
if (streams.length === 1) {
switch (streams.length) {
case 1:
fracsX = 1; fracsX = 1;
fracsY = 1; fracsY = 1;
} else if (streams.length === 2) { break;
case 2:
fracsX = 1; fracsX = 1;
fracsY = Math.max(Math.ceil(streams.length / 2), 2); fracsY = 2;
} else { break;
fracsX = Math.max(Math.ceil(streams.length / 2), 2); case 3:
fracsY = Math.max(Math.ceil(streams.length / 2), 2); case 4:
fracsX = 2;
fracsY = 2;
break;
default:
fracsX = Math.round(streams.length / 3);
fracsY = 3;
} }
}); });
</script> </script>
@ -31,9 +40,9 @@
<div <div
bind:this={containerElement} bind:this={containerElement}
class="streams" class="streams"
style={"grid-template-rows: repeat(" + style={"grid-template-columns: repeat(" +
fracsY + fracsY +
", 1fr); grid-template-columns: repeat(" + ", 1fr); grid-template-rows: repeat(" +
fracsX + fracsX +
", 1fr)"} ", 1fr)"}
> >