Narcoleptic's Patch Mangler
Miss any of our Open RFC calls?Watch the recordings here! »

has-scrolled

1.2.0 • Public • Published

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"
});

Keywords

none

Install

npm i has-scrolled

DownloadsWeekly Downloads

6

Version

1.2.0

License

ISC

Unpacked Size

9.74 kB

Total Files

6

Last publish

Collaborators

  • avatar