use_scroll
See Scrolling for how scroll containers work, and an example that renders only the rows in view.
API
counterweight.hooks.use_scroll
use_scroll(handle: ElementHandle | None = None) -> Scroll
| PARAMETER | DESCRIPTION |
|---|---|
handle
|
The element to report on, by the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Scroll
|
How far the element is scrolled, and how far it can be,
if it's a scroll container, as of the previous render cycle, as |
counterweight.hooks.Scroll
dataclass
How far a scroll container's content is scrolled, and how far it can be.
offset
instance-attribute
How far the content is scrolled from where layout put it: x columns left and y rows up,
so Position(0, 0) shows the start of the content, as the web's scrollLeft and scrollTop do.
max_offset
instance-attribute
The largest offset on each axis, which shows the end of the content,
as the web's scrollWidth minus clientWidth does.
It's 0 on an axis the container doesn't scroll, and on one whose content fits.
view_width
instance-attribute
view_width: int
The width of the container's padding box, the part of the content in view, as the web's clientWidth.
view_height
instance-attribute
view_height: int
The height of the container's padding box, the part of the content in view, as the web's clientHeight.