1.0.2 • Published 6 years ago

raf-bounce v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

RafBounce

Creates a debounced function throttled by requestAnimationFrame.

Why

Useful for implementing behavior that should only happen when the browser is ready, and after a repeated action has completed. Instead of forcing a browser repaint when the browser isn't ready (set intervals), this library will perform actions as fast as the browser allows. Another requestAnimationFrame call will not be made until the last execution has finished.

Installation

via npm

npm install raf-bounce --save

Example

let rafBounce = require('raf-bounce');

window.addEventListener('resize', rafBounce(onResize));

function onResize() {
	console.log('width', window.innerWidth);
	console.log('height', window.innerHeight);
}
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago