https://github.com/kodedninja/choo-resize
Resize Event plugin for Choo
https://github.com/kodedninja/choo-resize
Last synced: 8 months ago
JSON representation
Resize Event plugin for Choo
- Host: GitHub
- URL: https://github.com/kodedninja/choo-resize
- Owner: kodedninja
- Created: 2018-03-06T19:41:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-21T10:22:27.000Z (over 7 years ago)
- Last Synced: 2025-10-22T10:47:34.623Z (8 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# choo-resize
Resize Event plugin for Choo. It simply adds an event handler to the window and emits the ```state.events.RESIZE``` event.
## Installation
```
npm i -S choo-resize
```
## Example
```javascript
const choo = require('choo')
const resize = require('choo-resize')
const app = choo()
app.use(resize(true))
app.use(function (state, emitter) {
emitter.on(state.events.RESIZE, function () {
console.log('window resized')
})
})
app.route('*', require('./views/main'))
app.mount('body')
```
## API
### ```resize(render)```
Takes an optional argument. If true emits the ```state.events.RENDER``` event too. If you only need to render when the page's resized.