pub struct ScrollMetrics {
pub viewport: Size,
pub content: Size,
}Expand description
Viewport/content sizes used to clamp a scroll state.
§Examples
use ailloli_ui_core::{ScrollMetrics, Size};
let metrics = ScrollMetrics::new(Size::new(100.0, 80.0), Size::new(320.0, 240.0));
assert_eq!(metrics.viewport.w, 100.0);Fields§
§viewport: SizeVisible viewport size in logical pixels.
content: SizeFull scrollable content size in logical pixels.
Implementations§
Source§impl ScrollMetrics
impl ScrollMetrics
Sourcepub fn new(viewport: Size, content: Size) -> Self
pub fn new(viewport: Size, content: Size) -> Self
Creates metrics without normalizing either size.
§Examples
use ailloli_ui_core::{ScrollMetrics, Size};
let metrics = ScrollMetrics::new(Size::new(10.0, 20.0), Size::new(30.0, 40.0));
assert_eq!(metrics.content.h, 40.0);Sourcepub fn max_offset(self) -> Offset
pub fn max_offset(self) -> Offset
Returns the greatest non-negative logical offset on each axis.
Content smaller than its viewport produces zero. A non-finite subtraction also produces zero for that axis.
§Examples
use ailloli_ui_core::{Offset, ScrollMetrics, Size};
let metrics = ScrollMetrics::new(Size::new(100.0, 80.0), Size::new(320.0, 240.0));
assert_eq!(metrics.max_offset(), Offset::new(220.0, 160.0));Trait Implementations§
Source§impl Clone for ScrollMetrics
impl Clone for ScrollMetrics
Source§fn clone(&self) -> ScrollMetrics
fn clone(&self) -> ScrollMetrics
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ScrollMetrics
impl Debug for ScrollMetrics
Source§impl PartialEq for ScrollMetrics
impl PartialEq for ScrollMetrics
impl Copy for ScrollMetrics
impl StructuralPartialEq for ScrollMetrics
Auto Trait Implementations§
impl Freeze for ScrollMetrics
impl RefUnwindSafe for ScrollMetrics
impl Send for ScrollMetrics
impl Sync for ScrollMetrics
impl Unpin for ScrollMetrics
impl UnwindSafe for ScrollMetrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more