m = render(svelte`<!-- a -->
<script>
import {onMount} from 'svelte';
import {readable} from 'svelte/store';
let svg;
let svgRect = {width: undefined, height: undefined}
$: width = svgRect.width;
$: height = svgRect.height;
function maybeUpdateSvgRect() {
const rects = svg.getClientRects()
console.log(svg, rects, svg.getBoundingClientRect());
if (rects.length < 1) {
return false
}
svgRect = rects[0]
return true
}
export const refresh = maybeUpdateSvgRect
onMount(() => maybeUpdateSvgRect || setTimeout(maybeUpdateSvgRect, 0))
$: console.log({width, height})
</script>
<style>
svg {
display: block;
background: green;
}
</style>
<svelte:window on:resize='{maybeUpdateSvgRect}'/>
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" bind:this={svg} preserveAspectRatio="none">
<circle r=10 cx={width / 2} cy={height / 2} fill="black"/>
</svg>
`)