Skip to content
Halorav0.1.0

Behaviors

Header behavior

One scroll listener that flips one class.

Usage#

JavaScript
import { initHeader } from '@originlabsbr/halora/header';

const stop = initHeader({ selector: '.ha-header', threshold: 24, className: 'is-scrolled' });

The listener is passive and only touches the DOM when the state changes. It runs once on init, so a page that loads already scrolled starts in the pill state.

NameSignatureDescription
initHeader(options?) => destroyOptions: selector, threshold, className.
isScrolled(scrollY, threshold?) => booleanPure rule: scrollY > threshold.

See the Header component for the markup and the mobile layout.

Edit this page on GitHub

Type to search.