Answer the question
In order to leave comments, you need to log in
How to add numbers?
There are SVGs that have a viewBox.
It is necessary to add these numbers so that the result is 0 0 97 54 .
To do this, I looped through all the svg and got all the viewBox like this:
let svg = document.querySelectorAll("svg");
svg.forEach(function (el){
let viewbox = el.getAttribute("viewBox");
console.log(viewbox)
})
"0 0 33 18"
"0 0 33 9"
"0 0 31 27"
viewbox.reduce(function (a,b){return a+b;})
Answer the question
In order to leave comments, you need to log in
const viewBox = Array
.from(document.querySelectorAll('svg'), n => n.getAttribute('viewBox').split(' '))
.reduce((acc, n) => (n.forEach((m, i) => (acc[i] = (acc[i] || 0) + +m)), acc), [])
.join(' ');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question