use crate::BringIntoViewSpec;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct ScrollAxisRange {
pub value: f32,
pub max_value: f32,
pub reverse: bool,
pub content_padding_start: f32,
pub content_padding_end: f32,
pub bring_into_view_spec: BringIntoViewSpec,
}
impl ScrollAxisRange {
pub fn new(value: f32, max_value: f32, reverse: bool) -> Self {
Self {
value,
max_value,
reverse,
content_padding_start: 0.0,
content_padding_end: 0.0,
bring_into_view_spec: BringIntoViewSpec::Default,
}
}
pub fn with_content_padding(self, start: f32, end: f32) -> Self {
Self {
content_padding_start: start,
content_padding_end: end,
..self
}
}
pub fn with_bring_into_view_spec(self, bring_into_view_spec: BringIntoViewSpec) -> Self {
Self {
bring_into_view_spec,
..self
}
}
pub fn can_scroll_forward(&self) -> bool {
self.value < self.max_value
}
pub fn can_scroll_backward(&self) -> bool {
self.value > 0.0
}
}