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