diff --git a/src/actor/reactor/animation.rs b/src/actor/reactor/animation.rs index 6a46318d..2b26a3c3 100644 --- a/src/actor/reactor/animation.rs +++ b/src/actor/reactor/animation.rs @@ -34,6 +34,13 @@ pub struct Animation<'a> { impl<'a> Animation<'a> { pub fn new(fps: f64, duration: f64, _: AnimationEasing) -> Self { + // When fps is 0 (or negative), use the display's native refresh rate. + // Fall back to 60 Hz if the rate cannot be determined. + let fps = if fps > 0.0 { + fps + } else { + crate::sys::display_link::get_display_refresh_rate().unwrap_or(60.0) + }; let interval = Duration::from_secs_f64(1.0 / fps); // let now = unsafe { CFAbsoluteTimeGetCurrent() }; let now = Instant::now();