Skip to main content

ScrollDataSource

Trait ScrollDataSource 

Source
pub trait ScrollDataSource {
    // Required method
    fn get_offset(&self, node_id: NodeId) -> f32;
}
Expand description

A source of scroll offsets for scroll containers.

The layout engine calls get_offset for each LayoutOp::Scroll node to learn how far the user has scrolled. Platform backends implement this trait (or pass a closure, which also implements it).

§Example

use fission_layout::ScrollDataSource;
use fission_ir::NodeId;

// A closure works as a ScrollDataSource:
let source = |_node: NodeId| -> f32 { 0.0 };
assert_eq!(source.get_offset(NodeId::explicit("scroll")), 0.0);

Required Methods§

Source

fn get_offset(&self, node_id: NodeId) -> f32

Returns the current scroll offset for the given scroll container node.

Implementors§

Source§

impl<F> ScrollDataSource for F
where F: Fn(NodeId) -> f32,