Components
← All components

Intersection

stimeo--intersection

A declarative IntersectionObserver: visibility as events and CSS hooks.

  • Core

The stimeo--intersection controller is a thin declarative wrapper over IntersectionObserver — the scroll-triggered building block infinite scroll, count-up animations, reading progress, and smart sticky headers compose from. It observes its own element and turns visibility into transitions: enter when the element becomes visible (the intersection ratio reaches threshold), exit when it leaves (with the direction it went), passed when it fully crosses the root's start edge in either direction, and change on every observed update (set ratioSteps for a smooth ratio stream). The state is mirrored for CSS: data-intersecting, data-passed, and the --stimeo--intersection-ratio custom property — this demo is styled entirely from those hooks, with no consumer JS. The refresh action re-delivers the current state as a fresh transition, which un-stalls the classic hand-rolled infinite scroll whose sentinel never leaves the viewport. With once, the observer stops after the first enter (lazy loads, one-shot animations). connect() is idempotent: a Turbo cache restore does not re-fire enter for an element already recorded as visible.

running

Scroll inside the frame. The box reacts to its own visibility purely via CSS hooks — border and label from data-intersecting / data-passed, the fill bar from the ratio custom property.

Scroll down…

Visible Not visible yet Scrolled past

…and back up.