3.0.0 • Published 2 years ago

kea-window-values v3.0.0

Weekly downloads
2,161
License
MIT
Repository
github
Last release
2 years ago

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