sky-window

1.0.4 • Public • Published

sky-window

Simple js lightweight module for window events based on RxJs - handles resize and scroll events.

Dependencies

Usage

  1. Install RxJs
  2. Import sky-window
SkyWindow.resize.subscribe(() => {
    // On resize do what I type here
});

SkyWindow.scroll.subscribe(() => {
    // On scroll do what I type here
});

How it works

Sky-window uses hot observbles by invoking .share which is the same as .publish().refCount(). This means that when at least one instance is listening til e.g. resize it will run, but if refcount is 0 it will automaticly be unsubscribed. In addition resize will only fire 100ms after the last resize event.

resize: Observable.fromEvent(window, 'resize').share().debounce(() => Observable.timer(100)),
scroll: Observable.fromEvent(window, 'scroll').share(),

Credits

This module is made by the Frontenders at skybrud.dk. Feel free to use it in any way you want. Feedback, questions and bugreports should be posted as issues. Pull-requests appreciated!

Readme

Keywords

none

Package Sidebar

Install

npm i sky-window

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

192 kB

Total Files

9

Last publish

Collaborators

  • tfjordside
  • semilfred
  • ornhoj