Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-04-30 10:17:45 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-04-30 10:17:45 -0700
commit82d3a4b415ba920176058d615b697e84a49adabc (patch)
tree7bc250d9f332689e3dc0c4e7aec5949175a0f9fa /src/map.js
parenta4888a3e0905f3561781cb0ef4686befc0dff122 (diff)
Create record sheet dynamically when map is loaded
Diffstat (limited to 'src/map.js')
-rw-r--r--src/map.js13
1 files changed, 10 insertions, 3 deletions
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) {