window-resize

0.0.5 • Public • Published

window-resize

Optimised window resize function using requestAnimationFrame.

Since resize events can fire at a high rate, the event handler shouldn't execute computationally expensive operations such as DOM modifications. Instead, it is recommended to throttle the event using requestAnimationFrame.

Installation

npm i window-resize

Usage

import windowResize from 'window-resize'

function myOnResize() {
  console.log('on resize called')
}

windowResize.add(() => {
  myOnResize()
})

// to remove the resize listener call .clear()
windowResize.clear()

Package Sidebar

Install

npm i window-resize

Weekly Downloads

7

Version

0.0.5

License

ISC

Unpacked Size

3.46 kB

Total Files

4

Last publish

Collaborators

  • jonbloomer