From fd61d7d1f18c31237b3146cfc02e0641fd8a03e8 Mon Sep 17 00:00:00 2001 From: brahim <92426196+BrhmDev@users.noreply.github.com> Date: Tue, 17 Sep 2024 18:01:18 +0200 Subject: [PATCH] Refactor: don't combine horizontal splitters --- src/ZenViewSplitter.mjs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ZenViewSplitter.mjs b/src/ZenViewSplitter.mjs index cafe3ae..3cdea7d 100644 --- a/src/ZenViewSplitter.mjs +++ b/src/ZenViewSplitter.mjs @@ -379,15 +379,18 @@ var gZenViewSplitter = new class { for (let i = 0; i < rows.length; i++) { let nextRow = ''; finalTemplateAreas += `'`; - let buildingHSplitter = false; for (let j = 0; j < rows[i].length; j++) { const current = rows[i][j]; const rightNeighbor = rows[i][j + 1]; finalTemplateAreas += " " + current; - if (rightNeighbor && rightNeighbor !== current) { - finalTemplateAreas += ` vSplitter${vSplitterCount + 1}`; - vSplitterCount++; - splitters.push({nr: vSplitterCount, orient: 'vertical', gridIdx: j + 1}); + if (rightNeighbor) { + if (rightNeighbor !== current) { + finalTemplateAreas += ` vSplitter${vSplitterCount + 1}`; + vSplitterCount++; + splitters.push({nr: vSplitterCount, orient: 'vertical', gridIdx: j + 1, panels: current + 1}); + } else { + finalTemplateAreas += " " + current; + } } if (!rows[i + 1]) { @@ -396,19 +399,16 @@ var gZenViewSplitter = new class { const underNeighbor = rows[i + 1][j]; if (underNeighbor !== current) { nextRow += ` hSplitter${hSplitterCount + 1}`; - buildingHSplitter = true; + hSplitterCount++; + let panels = 1; + while (rows[i][j - panels] === current) { + panels++; + } + splitters.push({nr: hSplitterCount, orient: 'horizontal', gridIdx: i + 1, panels: panels}); } else { nextRow += ' ' + current; - hSplitterCount++; - splitters.push({nr: hSplitterCount, orient: 'horizontal', gridIdx: i + 1}); - buildingHSplitter = false; } if (j === rows[i].length - 1) { - if (buildingHSplitter) { - hSplitterCount++; - splitters.push({nr: hSplitterCount, orient: 'horizontal', gridIdx: i + 1}); - buildingHSplitter = false; - } continue; } const rightNeighborJoinedWithUnderNeighbor = rightNeighbor === rows[i + 1][j + 1];