final refactors
This commit is contained in:
@@ -15,6 +15,9 @@ use ratatui::widgets::{
|
||||
Widget, Wrap,
|
||||
};
|
||||
|
||||
/// Duration of the open and close animations, in seconds.
|
||||
const ANIM_SECS: f32 = 0.25;
|
||||
|
||||
/// Animation state for the scroll overlay window.
|
||||
#[derive(Default)]
|
||||
pub enum ScrollAnimState {
|
||||
@@ -54,11 +57,11 @@ impl ScrollOverlayState {
|
||||
pub fn advance_anim(&mut self, dt: f32) {
|
||||
match &mut self.anim {
|
||||
Some(ScrollAnimState::Opening(p)) => {
|
||||
*p += dt / 0.5;
|
||||
*p += dt / ANIM_SECS;
|
||||
if *p >= 1.0 { self.anim = Some(ScrollAnimState::Open); }
|
||||
}
|
||||
Some(ScrollAnimState::Closing(p)) => {
|
||||
*p -= dt / 0.5;
|
||||
*p -= dt / ANIM_SECS;
|
||||
if *p <= 0.0 { self.anim = Some(ScrollAnimState::Done); }
|
||||
}
|
||||
_ => {}
|
||||
|
||||
Reference in New Issue
Block a user