Web Dev Solutions

Catalin Mititiuc

From 82d3a4b415ba920176058d615b697e84a49adabc Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Tue, 30 Apr 2024 10:17:45 -0700 Subject: Create record sheet dynamically when map is loaded --- src/map.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/map.js') diff --git a/src/map.js b/src/map.js index 06b6ce6..e5c9cd4 100644 --- a/src/map.js +++ b/src/map.js @@ -4,16 +4,23 @@ const svg = document.querySelector('svg'); const gb = svg.querySelector('.gameboard'); const bg = svg.querySelector('#background'); const imageMaps = svg.querySelector('#image-maps'); - +const grid = gb.querySelector('.grid'); if ('cols' in dataset && 'rows' in dataset) { const cellTemplate = svg.querySelector('#hex'); - const grid = gb.querySelector('.grid'); createCells(grid, dataset, cellTemplate.id); } -setElAttrs(bg, calcComputedBboxFor(imageMaps)); +const sequence = getComputedStyle(gb).transform.match(/-?\d+\.?\d*/g); +const mtx = new DOMMatrix(sequence || ''); +bg.style.transform = mtx; + +const bbox = grid.getBBox(); + +bbox.height += 5; + +setElAttrs(bg, bbox); svg.setAttribute('viewBox', formatForViewBox(calcComputedBboxFor(gb))); function setElAttrs(el, attrs) { -- cgit v1.2.3