npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@brybrant/fade-scroll

v2.0.0

Published

Fade Scroll is a cosmetic module which adds subtle gradient masks to the overflow of scrollable content.

Readme

Fade Scroll

Fade Scroll is a cosmetic module which adds subtle gradient masks to the overflow of scrollable content.

See the demo page for an interactive demonstration.

[!IMPORTANT] Fade Scroll automatically injects the minimal CSS required. The visual fade effect is intentionally left to the user so that it can be customized freely. See fade-scroll.css for example styles which use CSS masks to blend seamlessly with any background. If you want to support legacy browsers, see fade-scroll--legacy.css for an example of how you can use linear gradients with pseudo elements to achieve a similar effect.

Install

$ npm i @brybrant/fade-scroll

Setup

<html>
  <head>
    <link rel='stylesheet' href='fade-scroll.css'/>
  </head>
  <body>
    <div id='horizontal'>
      <p>Some horizontal overflowing content...</p>
    </div>

    <div id='vertical'>
      <p>Some vertical overflowing content...</p>
    </div>

    <script type='module' src='index.js'></script>
  </body>
</html>
// index.js
import * as FadeScroll from '@brybrant/fade-scroll';

// Constructor with HTMLElement
const horizontal = new FadeScroll.Horizontal(
  document.getElementById<HTMLElement>('horizontal')!,
);

// Constructor with string (passed to `document.querySelector()`)
const vertical = new FadeScroll.Vertical('#vertical');

// Lifecycle begin
horizontal.mount();
vertical.mount();

// Set options
horizontal.captureWheel = true;
vertical.hideScrollbar = true;

// Change options
vertical.hideScrollbar = false;

// Lifecycle end
horizontal.destroy();
vertical.destroy();

API

The constructor requires only one argument:

HTMLElement or string (which is passed to querySelector())

This will become the content of the Fade Scroller.

The constructor returns a Fade Scroller:

Fade Scroller Properties:

content

The element selected in the first argument of the constructor function


scrollBar

The element with overflow (contains content element)


wrapper

The outer element (contains scrollBar element)


overflowSize

The size of the overflow

  • Type: number
  • Access: Read

|Horizontal|Vertical| |-|-| |content width minus wrapper width|content height minus wrapper height|


scrollPosition

The scroll position of the scrollBar element

  • Type: number
  • Access: Read / Write

|Horizontal|Vertical| |-|-| |scrollLeft|scrollTop|


hideScrollbar

Hide the scrollbar?

  • Type: boolean
  • Default: false
  • Access: Write

captureWheel (Horizontal only)

Capture wheel events and translate vertical to horizontal scroll movement?

  • Type: boolean
  • Default: false
  • Access: Write

Fade Scroller Methods:

mount()

  1. Adds the FadeScroll CSS classes.
  2. Adds wrapper and scrollBar to the DOM.
  3. Moves content to inside the scrollBar element.
  4. Starts observing content and wrapper elements.
  5. Adds the internal scroll event listener to scrollBar.

This will begin to add or remove CSS classes on the wrapper element in response to scrolling or size changes.

[!TIP] The mount() method returns this so you can construct a new Fade Scroller and then immediately mount it in a single assignment:

const scroller = new FadeScroll.Horizontal('.selector').mount();

console.log(scroller instanceof FadeScroll.Horizontal); // true

destroy()

  1. Removes the internal scroll event listener from scrollBar.
  2. Stops observing content and wrapper elements.
  3. Removes the FadeScroll CSS classes.
  4. Moves the content element to its original position in the DOM.
  5. Removes wrapper and scrollBar from the DOM.

[!TIP] A destroyed Fade Scroller can be mounted again by calling mount()


Browser Compatibility

The Fade Scroll demo uses CSS masks, but you may use linear gradients for better compatibility if the background is a solid color.

Fade Scroll requires the ResizeObserver API. Browsers without native support must provide a ponyfill using setResizeObserver() before constructing any scrollers:

import { ResizeObserver as Ponyfill } from '@juggle/resize-observer';

import * as FadeScroll from '@brybrant/fade-scroll';

FadeScroll.setResizeObserver(Ponyfill);

// Create some Fade Scrollers **after** setting the ponyfill...