Watch element resize in Svelte
npm i -S svelte-watch-resize
<script>
import { watchResize } from "svelte-watch-resize";
let leftWidth;
let mainWidth;
function handleLeftResize(node) {
leftWidth = node.clientWidth;
}
function handleMainResize(node) {
mainWidth = node.clientWidth;
}
</script>
<div class="root">
<div class="content leftContent" use:watchResize={handleLeftResize}>
{leftWidth}
</div>
<div class="content mainContent" use:watchResize={handleMainResize}>
{mainWidth}
</div>
</div>