Skip to content

ttt3pu/animation-frame-event-listener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

animation-frame-event-listener

A util that uses window.requestAnimationFrame to better performance of scroll/resize/etc 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');

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published