# obsize

> 🧐 Element size observer based on ResizeObserver

Latest version **0.0.2** (published 2023-05-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install obsize
pnpm add obsize
yarn add obsize
bun add obsize
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2023-05-18 |
| First published | 2023-05-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 255.4 KB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Yukiniro |
| Maintainers | yukiniro |
| Keywords | resize, observer, sensor, resizeobserver, element-size |

## Links

- npm: https://www.npmjs.com/package/obsize
- Repository: https://github.com/Yukiniro/obsize
- Homepage: https://github.com/Yukiniro/obsize#readme
- Issues: https://github.com/Yukiniro/obsize/issues
- npm.io page: https://npm.io/package/obsize

## Dependencies (1)

- [nanoid](https://npm.io/package/nanoid.md) ^4.0.2

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2023-05-18
- 0.0.1 — 2023-05-18

## README

# obsize

`obsize` is a tiny library that observes an element's size change.

## [Browser Compatibility](https://developer.mozilla.org/en-US/docs/Web/API/Resize_Observer_API#browser_compatibility)

- Chrome (64+)
- Edge (79+)
- Firefox (69+)
- Opera (51+)
- Safari (13.1+)

## Install

```shell
pnpm add obsize -S
npm install obsize -S
yarn add obsize -S
```

## Useage

```javascript
import { observe } from "../../src/index";

const unobserve = observe(element, () => { console.log('trigger') });

// call unobserve could remove the observe
unobserve()
```

## API

### `observe`

Observe the size of specified elements.

- Params
  - `element` - The element to be observer.
  - `fn` - The function to call when the element's size has changed.
  - `options` - Others cofnig.
    - `once` - It will auto-remove the observer when `fn` has been called.

### `clear`

Clear all observers for any elements.

## License

MIT license.

---
_Source: https://npm.io/package/obsize · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
