Scroll story
Pinned, in steps.New in 0.3: story() for sections that stay while you scroll.
The figure below is pinned with position: sticky, plain CSS. story() splits the scroll through the section into three steps and reports the active one. It also sets data-sigmoid-step and --sigmoid-progress on the section, so CSS alone can react.
Step 1 of 3
Pin with CSS
position: sticky keeps the content in place. No scroll hijacking.
Step 2 of 3
Count the steps
story() maps the contain range of the section to step 0, 1 and 2.
Step 3 of 3
React to them
A callback, a React hook or a data attribute: pick what fits.
story()
import { story } from "@sweberdev/sigmoid"
// <section id="how" style="height: 260vh">
// <div style="position: sticky; top: 0">…</div>
// </section>
story("#how", {
steps: 3,
onStep: (i) => show(i),
})