0.5.0 • Published 9 years ago

manage-scroll-handlers v0.5.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

manage-scroll-handlers NPM version Dependency Status

Add and remove scroll handlers to any DOM nodes. Doesn't block the event loop, and creates as few actual handlers as possible.

Installation

$ npm install --save manage-scroll-handlers

Usage

With import statement:

import { addScrollHandler, removeScrollHandler } from 'manage-scroll-handlers';

// Add scroll handler to window
addScrollHandler(() => console.log('1'));
addScrollHandler(() => console.log('2'));

// Add scroll handler to another element
addScrollHandler(() => console.log('3'), document.getElementById('scrollable-wrapper'));

// Add and remove scroll handlers
const callback = () => console.log('4');
addScrollHandler(callback);
removeScrollHandler(callback);

If you don't have import statements available, you can also do:

const { addScrollHandler, removeScrollHandler } = require('manage-scroll-handlers').default;

If you're stuck without babel at all, I don't envy you, but you can do this:

var manageScrollHandlers = require('manage-scroll-handlers').default;
var addScrollHandler = manageScrollHandlers.addScrollHandler;
var removeScrollHandler = manageScrollHandlers.removeScrollHandler;

License

MIT © Ben Berman

0.5.0

9 years ago

0.4.0

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.0

9 years ago