fix: accelerate geometry animations
This commit is contained in:
1 parent
bf4f5f77f7
commit
9f550e275c
2 files changed
+27
-6
No files matched your search
@@ -19,8 +19,8 @@ impl Default for SpringConfig {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
mass: 1.0,
|
mass: 1.0,
|
||||||
stiffness: 320.0,
|
stiffness: 700.0,
|
||||||
damping: 36.0,
|
damping: 53.0,
|
||||||
position_tolerance: 0.1,
|
position_tolerance: 0.1,
|
||||||
velocity_tolerance: 0.1,
|
velocity_tolerance: 0.1,
|
||||||
}
|
}
|
||||||
@@ -422,6 +422,27 @@ mod tests {
|
|||||||
assert_eq!(one_forty_four.current, target);
|
assert_eq!(one_forty_four.current, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn default_spring_completes_most_motion_within_two_hundred_milliseconds() {
|
||||||
|
let start = Rect::new(0.0, 0.0, 100.0, 100.0);
|
||||||
|
let target = Rect::new(500.0, 300.0, 900.0, 700.0);
|
||||||
|
let mut animated = AnimatedRect::new(start);
|
||||||
|
animated.set_target(target);
|
||||||
|
|
||||||
|
for _ in 0..12 {
|
||||||
|
animated.advance(Duration::from_secs_f64(1.0 / 60.0), SpringConfig::default());
|
||||||
|
}
|
||||||
|
|
||||||
|
assert!(animated.current.x >= 475.0);
|
||||||
|
assert!(animated.current.y >= 285.0);
|
||||||
|
assert!(animated.current.width >= 860.0);
|
||||||
|
assert!(animated.current.height >= 670.0);
|
||||||
|
assert!(animated.current.x <= target.x);
|
||||||
|
assert!(animated.current.y <= target.y);
|
||||||
|
assert!(animated.current.width <= target.width);
|
||||||
|
assert!(animated.current.height <= target.height);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn disabled_animation_snaps_to_target() {
|
fn disabled_animation_snaps_to_target() {
|
||||||
let mut geometry = WindowGeometry::new(Rect::new(0.0, 0.0, 100.0, 100.0), None);
|
let mut geometry = WindowGeometry::new(Rect::new(0.0, 0.0, 100.0, 100.0), None);
|
||||||
|
|||||||
@@ -574,8 +574,8 @@ to `visual.target`. Geometry uses spring animation; opacity, dimming, blur
|
|||||||
intensity, and overlays use bounded easing. Updates MUST use presentation or
|
intensity, and overlays use bounded easing. Updates MUST use presentation or
|
||||||
monotonic frame timestamps and MUST NOT assume a fixed refresh rate.
|
monotonic frame timestamps and MUST NOT assume a fixed refresh rate.
|
||||||
|
|
||||||
The default geometry spring uses mass `1.0`, stiffness `320.0`, and damping
|
The default geometry spring uses mass `1.0`, stiffness `700.0`, and damping
|
||||||
`36.0`, which is approximately critically damped. Geometry defaults MUST NOT
|
`53.0`, which is approximately critically damped. Geometry defaults MUST NOT
|
||||||
overshoot shared tile boundaries. User-configured underdamped geometry springs
|
overshoot shared tile boundaries. User-configured underdamped geometry springs
|
||||||
MAY overshoot numerically, but their rendered content remains clipped to the
|
MAY overshoot numerically, but their rendered content remains clipped to the
|
||||||
animated allocation and MUST NOT cover adjacent windows.
|
animated allocation and MUST NOT cover adjacent windows.
|
||||||
@@ -927,8 +927,8 @@ reduced_motion = false
|
|||||||
speed = 1.0
|
speed = 1.0
|
||||||
|
|
||||||
[animations.spring]
|
[animations.spring]
|
||||||
stiffness = 320.0
|
stiffness = 700.0
|
||||||
damping = 36.0
|
damping = 53.0
|
||||||
mass = 1.0
|
mass = 1.0
|
||||||
|
|
||||||
[tiling]
|
[tiling]
|
||||||
|
|||||||
Reference in new issue
Block a user