svg-center

Resize and center an svg element to its contents. Eliminates whitespace, and enables correct rescaling regarding width and height (provided ratio is constant)

Usage no npm install needed!

<script type="module">
  import svgCenter from 'https://cdn.skypack.dev/svg-center';
</script>

README

svg-center

Lets shrink our svg just to the elements being shown within it.

center = require('svg-center')


// shrink a single svg
center.shrink(document.getElementById('svg1'))

// or 

// shrink all svgs
center.shrinkall()