Behaviors
Particles
A quiet field of light points. Optional, and tuned to stay out of the way.
Usage#
<canvas class="ha-particles" aria-hidden="true"></canvas>import { startParticles } from '@originlabsbr/halora/particles';
const stop = startParticles({ canvas: '.ha-particles' });The landing page of this site runs it. It is generalized from the portfolio field.
What it does for performance and accessibility#
- Starts after first paint, 400ms later, through
requestIdleCallback, so it never competes with the largest paint. - Particle count scales with the viewport area, clamped to 24 to 160.
- The device pixel ratio is capped at 2 and drawing is limited to 30 frames per second.
- It pauses when the tab is hidden.
- Under reduced motion or the pause switch it draws one still frame and stops.
- It follows
data-themeanddata-brandon the root and re-tones itself. - The canvas is
aria-hiddenand haspointer-events: none.
API#
| Name | Signature | Description |
|---|---|---|
startParticles | ({ canvas?, palettes? }) => destroy | Start the field. Palettes are keyed by brand and theme. |
particleCount | (width, height) => number | One per 9000 square pixels, clamped to 24..160. |
createField, advance, resizeField, retone | pure functions | The simulation, testable without a canvas. |
depthFade | (z) => number | Fade in when far, out when near. |
PALETTES | { origin, gabarito } | rgb tones and a max alpha per theme. |