
Security News
AI Agent Lands PRs in Major OSS Projects, Targets Maintainers via Cold Outreach
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.
preact-scroll-header
Advanced tools
A (800b gzip) header that will show/hide while scrolling; for :atom_symbol: Preact
$ npm install --save preact-scroll-header
:exclamation: Pro Tip: Use Yarn to install dependencies 3x faster than NPM!
<script src="https://unpkg.com/preact-scroll-header@1.0.0/dist/preact-scroll-header.min.js"></script>
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>
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.
Type: String
Default: none
The id attribute to pass down.
Type: String
Default: none
The className attribute to pass down. Added to the wrapper element.
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.
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
transitionbefore this class (via base style orfixClass) will cause the<ScrollHeader/>to flicker into view before hiding.
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".
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.
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.
Type: Boolean
Default: false
Whether or not to disable the show/hide behavior. If true, will not add fixClass, readyClass, or showClass.
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.
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.
MIT © Luke Edwards
FAQs
A (800b gzip) header that will show/hide while scrolling
The npm package preact-scroll-header receives a total of 11 weekly downloads. As such, preact-scroll-header popularity was classified as not popular.
We found that preact-scroll-header demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.

Research
/Security News
Chrome extension CL Suite by @CLMasters neutralizes 2FA for Facebook and Meta Business accounts while exfiltrating Business Manager contact and analytics data.

Security News
After Matplotlib rejected an AI-written PR, the agent fired back with a blog post, igniting debate over AI contributions and maintainer burden.