Documentation
¶
Overview ¶
Package scrollspy attaches IntersectionObserver-based section tracking to any list of in-page anchors. As the user scrolls, the runtime sets `aria-current="true"` and `.is-active` on the anchor whose target is currently in view.
This is the standalone pattern extracted from the TOC widget's runtime — use it for sidebars, sticky in-page nav bars, or any list of `<a href="#id">` links that should reflect scroll position.
Wiring:
scrollspy.Wrap(scrollspy.Config{ObserveSelector: "main"},
nestedlist.Render(nestedlist.Config{ Items: ... }),
)
The wrapping element gains `data-fui-scrollspy="<selector>"` and the runtime auto-loads `scrollspy.js` on first appearance.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Style = registry.RegisterStyle("scrollspy", styleFn)
Style is the registered stylesheet handle. Wrap calls Style.WrapHTML so the data-fui-comp marker is emitted and the runtime auto-loads the CSS on first appearance.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// ObserveSelector is a CSS selector for the region whose anchored
// elements should be observed (e.g. "main", "article",
// ".doc-body"). Required.
ObserveSelector string
// TargetSelector overrides the default "h2[id], h3[id]" — set it
// when the section anchors aren't headings (e.g. "section[id]",
// "[data-spy]").
TargetSelector string
// Class is appended to the wrapper's class list.
Class string
// ID optionally tags the wrapper.
ID string
}
Config configures the scrollspy behavior.