Skip to content

maxrolon/raf-scroll.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple, performance optimized replacement for window.addEventListener('scroll', function(e) {...

The premiss for this module is to utilize animation frames to trigger scroll callbacks in the appropriate render pipeline location of each frame.

Install

npm i raf-scroll.js --save

Usage

import scroll from 'raf-scroll.js'

scroll( (y, prevY) => {
  //This callback will get executed on every scroll event..
})

The callback passed to the scroll function will get passed the current scrollY value (param 1) and the previous scrollY value (param 2). From this you will be able to ascertain scroll direction.

About

🚠 Performant scroll events with request animation frame

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published