# evented-viewport

> Viewport width and height utility for JavaScript modules.

Latest version **0.0.1** (published 2017-11-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install evented-viewport
pnpm add evented-viewport
yarn add evented-viewport
bun add evented-viewport
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2017-11-17 |
| First published | 2017-11-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Michael Cavalea |
| Maintainers | callmecavs |

## Links

- npm: https://www.npmjs.com/package/evented-viewport
- Repository: https://github.com/callmecavs/evented-viewport
- Homepage: https://github.com/callmecavs/evented-viewport#readme
- Issues: https://github.com/callmecavs/evented-viewport/issues
- npm.io page: https://npm.io/package/evented-viewport

## Recent versions

- 0.0.1 (latest) — 2017-11-17

## README

# evented-viewport

[![evented-viewport on NPM](https://img.shields.io/npm/v/evented-viewport.svg?style=flat-square)](https://www.npmjs.com/package/evented-viewport) [![evented-viewport Downloads on NPM](https://img.shields.io/npm/dm/evented-viewport.svg?style=flat-square)](https://www.npmjs.com/package/evented-viewport) [![Standard JavaScript Style](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)

Viewport width and height utility for JavaScript modules.

## Install

```sh
$ npm i evented-viewport --save
```

## Usage

Pass `evented-viewport` an options object with `debounce` and `emitter` properties:

```javascript
import knot from 'knot.js'
import viewport from 'evented-viewport'

// have your emitter handy (create or import one)
const emitter = knot()

// (optionally) subscribe to the resize event
// note that all handlers will be passed an object containing the viewport width/height
emitter
  .on('resize', viewport => console.log(`width: ${ viewport.width }`))
  .on('resize', viewport => console.log(`height: ${ viewport.height }`))

// define your options
const options = {
  debounce: 250,      // time, in ms, that must pass before updating the viewport width/height on resize
  emitter             // object with an "emit" method
}

// create an instance (should be a singleton)
const instance = viewport(options)

// export (and enjoy in other modules)
export default instance
```

## See Also

* [knot.js](https://github.com/callmecavs/knot.js) - A browser-based event emitter, for tying things together.

## License

[MIT](https://opensource.org/licenses/MIT). © 2017 Michael Cavalea

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