New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

scroll-watcher

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scroll-watcher

A lightweight, blazing fast, rAF based, scroll watcher.

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
190
decreased by-0.52%
Maintainers
1
Weekly downloads
 
Created
Source

scroll-watcher

A lightweight, blazing fast, rAF based, scroll watcher.

A more up-to-date approach to this scrolling watchers stuff. Slightly inspired by scrollMonitor.

Demos

Scrolling, Moving and Recalculating

Static Website Menu

How to use it?

→ CDN Hosted - jsDelivr
<script src="//cdn.jsdelivr.net/scroll-watcher/latest/scroll-watcher.min.js"></script>
→ Self hosted

Download latest release.

NPM
npm install scroll-watcher
Instantiate and watch for a specific (or a list) DOM element
var scroll = new ScrollWatcher();
scroll.watch('my-element')
  .on('enter', function (evt) {
    console.log('I'm partially inside viewport');
  })
  .on('exit', function (evt) {
    console.log('I'm out of viewport');
  })
  .on('enter:full', function (evt) {
    console.log('I'm entirely within the viewport');
  })
  .on('exit:partial', function (evt) {
    console.log('I'm partially out of viewport');
  });

Events on/once/off

You can simply watch for scrolling action:

var watcher = new ScrollWatcher();
watcher.on('scrolling', function(evt) {
  console.log(evt);
});

// or just once
watcher.once('scrolling', function(evt) {
  console.log(evt);
});

// and turn it off (later)
watcher.off('scrolling');

Credits

Thanks to @scottcorgan for his great tiny-emitter.

License

Unlicense

FAQs

Package last updated on 01 Oct 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc