Skip to main content

ScrollManager

Struct ScrollManager 

Source
pub struct ScrollManager { /* private fields */ }
Expand description

Manages all scroll state and animations for a window

Implementations§

Source§

impl ScrollManager

Source

pub fn new() -> Self

Creates a new empty ScrollManager

Source

pub fn begin_frame(&mut self)

Prepares state for a new frame by saving current offsets as previous

Source

pub fn end_frame(&self) -> FrameScrollInfo

Returns scroll activity summary for the completed frame

Source

pub fn tick(&mut self, now: Instant) -> ScrollTickResult

Advances scroll animations by one tick, returns repaint info

Source

pub fn process_scroll_event(&mut self, event: ScrollEvent, now: Instant) -> bool

Processes a scroll event, applying immediate or animated scroll

Source

pub fn record_sample( &mut self, delta_x: f32, delta_y: f32, hover_manager: &HoverManager, input_point_id: &InputPointId, now: Instant, ) -> Option<(DomId, NodeId)>

Records a scroll input sample and applies it to the first scrollable node under the cursor

Finds the first scrollable node in the hit test hierarchy and applies the scroll delta. Returns the scrolled node if successful.

Source

pub fn get_scroll_delta( &self, dom_id: DomId, node_id: NodeId, ) -> Option<LogicalPosition>

Returns the scroll delta applied this frame, if non-zero

Source

pub fn had_scroll_activity_for_node( &self, dom_id: DomId, node_id: NodeId, ) -> bool

Returns true if the node had scroll activity this frame

Source

pub fn set_scroll_position( &mut self, dom_id: DomId, node_id: NodeId, position: LogicalPosition, now: Instant, )

Sets scroll position immediately (no animation)

Source

pub fn scroll_by( &mut self, dom_id: DomId, node_id: NodeId, delta: LogicalPosition, duration: Duration, easing: EasingFunction, now: Instant, )

Scrolls by a delta amount with animation

Source

pub fn scroll_to( &mut self, dom_id: DomId, node_id: NodeId, target: LogicalPosition, duration: Duration, easing: EasingFunction, now: Instant, )

Scrolls to an absolute position with animation

If duration is zero, the position is set immediately without animation.

Source

pub fn update_node_bounds( &mut self, dom_id: DomId, node_id: NodeId, container_rect: LogicalRect, content_rect: LogicalRect, now: Instant, )

Updates the container and content bounds for a scrollable node

Source

pub fn get_current_offset( &self, dom_id: DomId, node_id: NodeId, ) -> Option<LogicalPosition>

Returns the current scroll offset for a node

Source

pub fn get_last_activity_time( &self, dom_id: DomId, node_id: NodeId, ) -> Option<Instant>

Returns the timestamp of last scroll activity for a node

Source

pub fn get_scroll_state( &self, dom_id: DomId, node_id: NodeId, ) -> Option<&AnimatedScrollState>

Returns the internal scroll state for a node

Source

pub fn get_scroll_states_for_dom( &self, dom_id: DomId, ) -> BTreeMap<NodeId, ScrollPosition>

Returns all scroll positions for nodes in a specific DOM

Source

pub fn register_or_update_scroll_node( &mut self, dom_id: DomId, node_id: NodeId, container_rect: LogicalRect, content_size: LogicalSize, now: Instant, )

Registers or updates a scrollable node with its container and content sizes. This should be called after layout for each node that has overflow:scroll or overflow:auto with overflowing content.

If the node already exists, updates container/content rects without changing scroll offset. If the node is new, initializes with zero scroll offset.

Source

pub fn register_scroll_node( &mut self, dom_id: DomId, node_id: NodeId, ) -> ExternalScrollId

Register a scroll node and get its ExternalScrollId for WebRender. If the node already has an ID, returns the existing one.

Source

pub fn get_external_scroll_id( &self, dom_id: DomId, node_id: NodeId, ) -> Option<ExternalScrollId>

Get the ExternalScrollId for a node (returns None if not registered)

Source

pub fn iter_external_scroll_ids( &self, ) -> impl Iterator<Item = ((DomId, NodeId), ExternalScrollId)> + '_

Iterate over all registered external scroll IDs

Source

pub fn calculate_scrollbar_states(&mut self)

Calculate scrollbar states for all visible scrollbars. This should be called once per frame after layout is complete.

Source

pub fn get_scrollbar_state( &self, dom_id: DomId, node_id: NodeId, orientation: ScrollbarOrientation, ) -> Option<&ScrollbarState>

Get scrollbar state for hit-testing

Source

pub fn iter_scrollbar_states( &self, ) -> impl Iterator<Item = ((DomId, NodeId, ScrollbarOrientation), &ScrollbarState)> + '_

Iterate over all visible scrollbar states

Source

pub fn hit_test_scrollbar( &self, dom_id: DomId, node_id: NodeId, global_pos: LogicalPosition, ) -> Option<ScrollbarHit>

Hit-test scrollbars for a specific node at the given position. Returns Some if the position is inside a scrollbar for this node.

Source

pub fn hit_test_scrollbars( &self, global_pos: LogicalPosition, ) -> Option<ScrollbarHit>

Perform hit-testing for all scrollbars at the given global position.

This iterates through all visible scrollbars in reverse z-order (top to bottom) and returns the first hit. Use this when you don’t know which node to check.

For better performance, use hit_test_scrollbar() when you already have a hit-tested node from WebRender.

Source§

impl ScrollManager

Source

pub fn remap_node_ids( &mut self, dom_id: DomId, node_id_map: &BTreeMap<NodeId, NodeId>, )

Remap NodeIds after DOM reconciliation

When the DOM is regenerated, NodeIds can change. This method updates all internal state to use the new NodeIds based on the provided mapping.

Trait Implementations§

Source§

impl Clone for ScrollManager

Source§

fn clone(&self) -> ScrollManager

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScrollManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ScrollManager

Source§

fn default() -> ScrollManager

Returns the “default value” for a type. Read more
Source§

impl EventProvider for ScrollManager

Source§

fn get_pending_events(&self, timestamp: Instant) -> Vec<SyntheticEvent>

Get pending scroll events.

Returns Scroll/ScrollStart/ScrollEnd events for nodes whose scroll position changed this frame.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool