New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

raf-scroll

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raf-scroll

A scroll event that fires only once per frame.

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

raf-scroll

A scroll event that fires only once per frame.

Installation

npm i raf-scroll --save

Usage

rafScroll.add(callback) Will call callback maximum once per frame, if the scroll value has changed. An event will be passed containing the current scrollY as well as the deltaY.

rafScroll.addOnce(callback) Same than add but only trigger the event once, then automatically unbinds itself. Useful for triggering behavior when user scrolls.

rafScroll.remove(callback) Unbind the listener. Passing no callback will unbind all previous callbacks.

rafScroll.getCurrent() Manually get the event (containing last scrollY/deltaY).

rafScroll.destroy() Clean the singleton. It will auto-restart if you call rafScroll.add again.

Example


var rafScroll = require('raf-scroll');

rafScroll.add(function onScroll(event) {
  if (window.innerHeight + event.scrollY >= document..offsetHeight - window.innerHeight * 0.5) {
    triggerInfiniteScroll();
  }
}

Keywords

raf

FAQs

Package last updated on 21 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts