Element resize observer to Svelte
npm i svelte-resize-observer
// OR
yarn add svelte-resize-observer
Note: to use this library in sapper, install as devDependency. See the link.
Demo Link
Local demo:
git clone https://github.com/andrelmlins/svelte-resize-observer.git
cd svelte-resize-observer
npm install && npm run dev
An example of how to use the library:
<script>
import ResizeObserver from "svelte-resize-observer";
</script>
<style>
div {
width: 400px;
height: 400px;
}
</style>
<div>
<ResizeObserver on:resize={(e) => console.log(e.detail.target)} />
</div>
Component props:
Prop | Type | Description |
---|---|---|
elementResize | node | Element to bind resize |
resize | func | Call with resize |
Download stats for this NPM package
Svelte Resize Observer is open source software licensed as MIT.