Skip to content

keajs/kea-window-values

Repository files navigation

NPM Version minified minified + gzipped Backers on Open Collective Sponsors on Open Collective

kea-window-values

  • Sync window.whatever with values.anything.
  • Sync on window onscroll & onresize events.

Installation

  import { windowValuesPlugin } from 'kea-window-values'

  resetContext({
    plugins: [windowValuesPlugin({ window: window })]
  }),

Usage

  kea({
    windowValues: {
      isSmallScreen: window => window.innerWidth < 640,
      isRetina: window => window.devicePixelRatio > 2,
      scrollBarWidth: window => window.innerWidth - window.body.clientWidth
    }
  })

Sample usage

Read the documentation

About

Sync `window.whatever` with `values.anything`

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published