frust_widgets/physics/effect.rs
1//! How overscroll displacement/pull is **visualized**, independent of the
2//! [`ScrollPhysics`](super::ScrollPhysics) that computes it — a clamping
3//! physics rejecting 100% of a boundary proposal still has an `edge_pull` to
4//! paint an effect from (see the [module docs](super)'s design ruling), and a
5//! bouncing physics letting the position itself move past the edge can be
6//! paired with any of these the same way.
7//!
8//! [`OverscrollEffect::Stretch`]'s intensity curve is an affine approximation
9//! of Android 12's overscroll shader — the same class Flutter's non-Impeller
10//! `StretchingOverscrollIndicator` implements — but the curve's constants live
11//! with the paint-time application that reads them, not here; this type is
12//! only the selector.
13
14/// How overscroll displacement/pull is VISUALIZED — orthogonal to physics.
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
16pub enum OverscrollEffect {
17 /// Translate the content by the overscroll displacement (today's behavior).
18 #[default]
19 Translate,
20 /// M3E stretch: paint-side affine scale about the pulled edge; content
21 /// origin stays fixed. Intensity reads the widget's edge_pull.
22 Stretch,
23 /// No visual at all.
24 None,
25}
26
27#[cfg(test)]
28mod tests {
29 use super::*;
30
31 #[test]
32 fn overscroll_effect_default_is_translate() {
33 assert_eq!(OverscrollEffect::default(), OverscrollEffect::Translate);
34 }
35}