1.1.0 • Published 6 years ago

@gen-tech/scroll-manager v1.1.0

Weekly downloads
14
License
MIT
Repository
github
Last release
6 years ago

@gen-tech/scroll-manager

travis Coverage Status npm npm TypeScript patreon license

Improved Scroll Events & Scroll Management for web development

Supports horizontal scroll

Written with Typescript

Built with Rxjs

Installation

npm install @gen-tech/scroll-manager --save

Usage

import scrollManager from "@gen-tech/scroll-manager";

const target = document.querySelector(".scrollable-div");

// Create an observer for the target
const observer = scrollManager.observe(target);

/**
 * Subscribe to targets scrollY events
 */
observer.scrollY.subscribe(position => {
  console.log(position);
});

/**
 * To track window scroll, use `root`
 */
scrollManager.root.scrollY.subscribe(position => {
  console.log(position);
});

Some of Available Scroll Event Streams

// Scroll Start
observer.scrollStart.subscribe(position => {
  // {top: number, left: number}
});

// Scroll End
observer.scrollEnd.subscribe(position => {
  // {top: number, left: number}
});

// Scroll Direction Change
observer.scrollDirectionChange.subscribe(position => {
  // 1, 2, 4, 8 (TOP, BOTTOM, LEFT, RIGHT)
});

// Scrolling Down
observer.scrollingDown.subscribe(position => {
  // number
});


// Remaining scrollable area to the right in pixels
observer.remainingX.subscribe(position => {
  // number
});

Performance

By default, scroll-manager throttles scroll events in every 90ms for performance prospects

If you want to capture all events use const observer = scrollManager.observe(target, 0);

Api Documentation

gen-tech.github.io/scroll-manager

License

MIT

1.1.0

6 years ago

1.0.0

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.1

6 years ago

0.2.0

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago

0.0.0

7 years ago