State object you can listen to for changes to window width.
Last updated 6 years ago by henrikjoreteg .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install window-watcher 
SYNC missed versions from official npm registry.


Simple CommonJS module for easily listening to changes to window width.

The idea here is to unify code that cares about changes to window size.

It also uses requestAnimationFrame (or fallback) where possible to optimize for rendering something in response to change. You can of course deboune handler further, but you get a bit of sane built-in debounce out of the box.

Also, it uses "backbone style" events. So from an ampersand-view, or backbone-view you can listenTo this one shared state object from several view and know that it'll get automatically unbound when the view is destroyed.


npm install window-watcher


var ww = require('window-watcher');

ww.on('resize', function () {
    // request animation frame debounced callback

ww.width; // this is shortcut to window.innerWidth;
ww.height; // this is shortcut to window.innerHeight;


If you like this follow @HenrikJoreteg on twitter.



Current Tags

  • 1.0.0                                ...           latest (6 years ago)

3 Versions

  • 1.0.0                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.0                                ...           7 years ago
Maintainers (1)
Today 0
This Week 0
This Month 2
Last Day 1
Last Week 1
Last Month 6
Dependencies (2)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2016 © |