pub struct ScrollBehavior {
pub axes: ScrollAxes,
pub line_px: f32,
}Expand description
Wheel normalization and per-widget scroll tuning.
§Examples
use ailloli_ui_core::{ScrollAxes, ScrollBehavior};
let behavior = ScrollBehavior::new(ScrollAxes::VERTICAL);
assert_eq!(behavior.line_px, ScrollBehavior::DEFAULT_LINE_PX);Fields§
§axes: ScrollAxesAxes that receive normalized wheel motion.
line_px: f32Logical pixels represented by one platform line unit.
Implementations§
Source§impl ScrollBehavior
impl ScrollBehavior
Sourcepub const DEFAULT_LINE_PX: f32 = 48f32
pub const DEFAULT_LINE_PX: f32 = 48f32
Default logical distance of one wheel line: 48 pixels.
§Examples
use ailloli_ui_core::ScrollBehavior;
assert_eq!(ScrollBehavior::DEFAULT_LINE_PX, 48.0);Sourcepub fn new(axes: ScrollAxes) -> Self
pub fn new(axes: ScrollAxes) -> Self
Creates behavior for axes using Self::DEFAULT_LINE_PX.
§Examples
use ailloli_ui_core::{ScrollAxes, ScrollBehavior};
assert_eq!(ScrollBehavior::new(ScrollAxes::BOTH).axes, ScrollAxes::BOTH);Sourcepub fn with_line_px(self, line_px: f32) -> Self
pub fn with_line_px(self, line_px: f32) -> Self
Sets the line distance, clamped to at least one logical pixel.
NaN and negative infinity become 1.0 through floating-point max
semantics; positive infinity remains infinite.
§Examples
use ailloli_ui_core::{ScrollAxes, ScrollBehavior};
assert_eq!(ScrollBehavior::new(ScrollAxes::BOTH).with_line_px(0.0).line_px, 1.0);Sourcepub fn wheel_delta(self, delta: WheelDelta) -> Offset
pub fn wheel_delta(self, delta: WheelDelta) -> Offset
Converts a platform wheel delta to a filtered logical content offset.
Line deltas are scaled by Self::line_px; pixel deltas are already in
logical pixels. Both forms are negated so a positive wheel delta moves
the viewed content toward its origin.
§Examples
use ailloli_ui_core::{Offset, ScrollAxes, ScrollBehavior};
use ailloli_ui_core::event::WheelDelta;
let delta = ScrollBehavior::new(ScrollAxes::VERTICAL).wheel_delta(WheelDelta::LineDelta { x: 1.0, y: -2.0 });
assert_eq!(delta, Offset::new(0.0, 96.0));Sourcepub fn wheel_delta_with_modifiers(
self,
delta: WheelDelta,
modifiers: Modifiers,
) -> Offset
pub fn wheel_delta_with_modifiers( self, delta: WheelDelta, modifiers: Modifiers, ) -> Offset
Converts wheel input while applying the framework’s Shift-axis policy.
Line values use Self::line_px and pixel values are already logical.
Native horizontal movement is preserved. When Shift is held and the
horizontal axis is enabled, normalized vertical movement is added to X
and removed from Y. Vertical-only surfaces therefore keep scrolling
vertically under Shift. Non-finite components become zero.
The provider’s precise flag is intentionally absent: line-versus-pixel
already determines scaling, while precision remains event metadata and
does not introduce acceleration.
§Examples
use ailloli_ui_core::{event::{Modifiers, WheelDelta}, Offset, ScrollAxes, ScrollBehavior};
let modifiers = Modifiers { shift: true, ..Modifiers::default() };
let delta = ScrollBehavior::new(ScrollAxes::BOTH).with_line_px(10.0)
.wheel_delta_with_modifiers(WheelDelta::LineDelta { x: -1.0, y: -2.0 }, modifiers);
assert_eq!(delta, Offset::new(30.0, 0.0));Trait Implementations§
Source§impl Clone for ScrollBehavior
impl Clone for ScrollBehavior
Source§fn clone(&self) -> ScrollBehavior
fn clone(&self) -> ScrollBehavior
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more