animation-frame-event-listener
v1.1.2
Published
Util for better performance on scroll/resize eventListener.
Downloads
5
Readme
animation-frame-event-listener
A util that uses window.requestAnimationFrame to better performance of scroll/resize event listeners.
usage
import {addAnimationFrameEventListener, removeAnimationFrameEventListener} from 'animation-frame-event-listener';
const exampleCallBack = () => {
console.log(window.scrollY);
};
// addEvent
addAnimationFrameEventListener(window, 'scroll', 'anyUniqueIdForEvent', exampleCallBack);
// removeEvent
removeAnimationFrameEventListener(window, 'anyUniqueIdForEvent');