Behaviors
Header behavior
One scroll listener that flips one class.
Usage#
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.
| Name | Signature | Description |
|---|---|---|
initHeader | (options?) => destroy | Options: selector, threshold, className. |
isScrolled | (scrollY, threshold?) => boolean | Pure rule: scrollY > threshold. |
See the Header component for the markup and the mobile layout.