
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
affixing-header
Advanced tools
An affixing header that behaves normally as a user navigates down a page, but reveals itself naturally when a user scrolls or drags upwards. Inspired by iOS Safari, Medium, and others.
Create an affixing header that behaves normally as a user navigates down a page, but reveals itself naturally when a user scrolls or drags upwards. Inspired by iOS Safari, Medium, and others. See an example implementation to see what it’s about. Works on desktop and mobile browsers.
The module is ESM-only and exports a single default affixingHeader
function:
affixingHeader( element, options )
element
HTMLElementThe DOM element to which the affixing behavior should be attached. Must be a single HTMLElement
(e.g., the result of document.querySelector
or document.getElementById
), not a NodeList
.
options
object { classNameAffixed?: string; classNameAffixing?: string; useSticky?: boolean }
Optional options for customizing the behavior of the affixing header:
{ classNameAffixed: string }
will add the specified class to the header when it is affixed (i.e. when it has been scrolled up){ classNameAffixing: string }
will add the specified class to the header when it is in the process of affixing (i.e. when the user has started scrolling up and the header is moving into view){ useSticky: true }
will cause the module to use position: sticky
(instead of position: fixed
) when affixing the header on scrolling upaffixingHeader
function (element: HTMLElement) => () => void
The affixingHeader
function returns a cleanup function that takes no arguments and is used to remove listeners and cleanup the affixing behavior.
This package uses onscrolling, a requestAnimationFrame-based, performant, mobile-friendly scroll event handler, to listen for page scrolls, but has no other dependencies.
This module is ESM-only and takes advantage of modern JS language features. It includes code to ensure it won’t throw errors in non-browser environments (e.g. node, workersd, deno, bun, etc.), where it will not do anything but also won’t break SSR. To make it compatible with non-ESM environments and older browsers, it must be transpiled.
Tests use vitest + happy-dom and can be run with yarn test
.
{ scrollingParent: DOMElement }
option for usage with scrollable elements other than scrollingDocument
FAQs
An affixing header that behaves normally as a user navigates down a page, but reveals itself naturally when a user scrolls or drags upwards. Inspired by iOS Safari, Medium, and others.
The npm package affixing-header receives a total of 100 weekly downloads. As such, affixing-header popularity was classified as not popular.
We found that affixing-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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.