Skip to main content

compute_scrollbar_geometry

Function compute_scrollbar_geometry 

Source
pub fn compute_scrollbar_geometry(
    orientation: ScrollbarOrientation,
    inner_rect: LogicalRect,
    content_size: LogicalSize,
    scroll_offset: f32,
    scrollbar_width_px: f32,
    has_other_scrollbar: bool,
) -> ScrollbarGeometry
Expand description

Compute scrollbar geometry for one axis.

This is the single source of truth for all scrollbar calculations. All consumers (display list painting, GPU transforms, hit-testing, drag) must use this function to ensure consistent geometry.

§Parameters

  • orientation: Vertical or horizontal scrollbar
  • inner_rect: The padding-box (border-box minus borders) of the scroll container, in the container’s coordinate space (absolute window coordinates)
  • content_size: Total content size (from get_content_size() or virtual_scroll_size)
  • scroll_offset: Current scroll offset (y for vertical, x for horizontal; positive = scrolled)
  • scrollbar_width_px: CSS-resolved scrollbar thickness in pixels
  • has_other_scrollbar: Whether the perpendicular scrollbar is also visible (reduces track length by one scrollbar_width_px for the corner)