1.2.0 • Published 4 years ago

has-scrolled v1.2.0

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

Has Scrolled

Add scroll info to elements.

Install

npm i has-scrolled

Integrate

import hasScrolled from "has-scrolled";
hasScrolled();

Or, if you're compiling your own Typescript like a good little dev

import hasScrolled from "has-scrolled/index";
hasScrolled();

That's all well and good, but what does it do?

As you scroll down, it'll add a class and data attributes like so:

<body class="has-scrolled" data-scroll-y="120"></body>

Moar Powar!

If you want scroll info for within another element, for it to add a suffixed class to a separate element, or tweak any other default config values:

hasScrolled({
  element: document.querySelector("nav"),
  target: document.querySelector("body"),
  minScroll: 100,
  scrollTolerance: 50,
  class: "has-scrolled-foo"
});
1.2.0

4 years ago

1.1.0

4 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago