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

preact-scroll-header

v1.0.3

Published

A (800b gzip) header that will show/hide while scrolling

Downloads

35

Readme

preact-scroll-header NPM

A (800b gzip) header that will show/hide while scrolling; for :atom_symbol: Preact

Demo (standard)

Demo (inverse)

Install

$ npm install --save preact-scroll-header

:exclamation: Pro Tip: Use Yarn to install dependencies 3x faster than NPM!

<script src="https://unpkg.com/[email protected]/dist/preact-scroll-header.min.js"></script>

Usage

Provide a value; everything else is optional.

import { h } from 'preact';
import ScrollHeader from 'preact-scroll-header';

<ScrollHeader
  id="header" className="menu"
  buffer={ 24 } showClass="menu-show"
  onShow={ el => console.log('SHOWN', el) }
  onHide={ el => console.log('HIDDEN', el) }>
  <h1>Menu</h1>
</ScrollHeader>

Styles

This component does not include any inline styles. Instead, classnames are assigned for every state the <ScrollHeader/> enters. This provides greater flexibility and control of your desired effects!

However, there are some strong guidelines which you should not neglect. Below is an example for a simple slide-down effect:

/* start with "shown" position */
/* will-change, top, right, left early to avoid extra repaints */
.header {
  position: relative;
  will-change: transform;
  transform: translateY(0%);
  right: 0;
  left: 0;
  top: 0;
}

/* apply fixed; set start point */
.is--fixed {
  position: fixed;
  transform: translateY(-100%);
}

/* apply transition separately; no flicker */
.is--ready {
  transition: transform 0.2s ease-in-out;
}

/* set end point; with shadow */
.is--shown {
  transform: translateY(0%);
  box-shadow: 0 3px 6px rgba(0,0,0, 0.16);
}

Note: Assumes that "header" was added as your base className. All others are defaults.

Properties

id

Type: String Default: none

The id attribute to pass down.

className

Type: String Default: none

The className attribute to pass down. Added to the wrapper element.

fixClass

Type: String Default: 'is--fixed'

The className to add when the header is out of view. This should apply a position:fixed style, as well as an initial transform value.

readyClass

Type: String Default: 'is--ready'

The className to add when the header has been "fixed". This should apply a transition value to your header, which should always be separated from your fixClass.

Note: Applying a transition before this class (via base style or fixClass) will cause the <ScrollHeader/> to flicker into view before hiding.

showClass

Type: String Default: 'is--shown'

The className to add when the header should be revealed. This should apply your desired transform effect. Class is only applied when the <ScrollHeader/> is out of view and has been "fixed".

buffer

Type: Number Default: 0

The number of pixels to scroll before applying your showClass. By default, the <ScrollHeader/> will be shown immediately after user scrolls up.

listenTo

Type: String Default: this.base.parentNode

The "scroller" element that will fire scroll events. Works well with customized viewports, where document.body is not scrollable and/or controlling overflow.

disabled

Type: Boolean Default: false

Whether or not to disable the show/hide behavior. If true, will not add fixClass, readyClass, or showClass.

onShow

Type: Function

The callback function when the header is to be shown. Receivies the DOM element as its only argument, but is bound to the ScrollHeader component context.

onHide

Type: Function

The callback function when the header is to be hidden. Receivies the DOM element as its only argument, but is bound to the ScrollHeader component context.

License

MIT © Luke Edwards