Skip to content

andrelmlins/svelte-resize-observer

Repository files navigation

Svelte Resize Observer

npm versionLicense: MITBuild StatusNetlify StatusLanguage grade: JavaScript

Element resize observer to Svelte

Installation

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

Examples

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>

Properties

Component props:

Prop Type Description
elementResize node Element to bind resize
resize func Call with resize

NPM Statistics

Download stats for this NPM package

NPM

License

Svelte Resize Observer is open source software licensed as MIT.