A block that sticks to the top of the page and takes classes while the page is scrolled: a header that gets an edge, a bar that gets a shadow.
<.sticky id="page-bar" stuck_class="shadow-md">...</.sticky>The hook LedgerUI.Sticky (priv/static/ledger_ui/hooks/sticky.js) adds stuck_class and sets
data-stuck once the page is scrolled past offset pixels, and takes them off when it is back.
The block is position: sticky; top: 0.
Preview
preview draws the canvas picture of the behavior: a frame (lu-sticky) with the :header slot on a
translucent bar and the content scrolling under it (body_class / body_style go to the content, for
the scrolling animation). No hook. For the documentation and the showcase only.
<.sticky id="demo" preview body_class="mo-scroll" body_style="--sy:-160px">
<:header>Orders today</:header>
<i style="width:90%"></i>
</.sticky>
Summary
Functions
Attributes
id(:string) (required)offset(:integer) - Pixels the page scrolls before the block counts as stuck. Defaults to0.stuck_class(:string) - Classes added while stuck. Without it the hook draws a 1px bottom line. Defaults tonil.preview(:boolean) - The canvas picture of a sticky header. Defaults tofalse.body_class(:string) - Withpreview: extra classes of the content. Defaults tonil.body_style(:string) - Withpreview: the style of the content. Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block(required)header- Withpreview: the content of the bar.