Rename Animation::in_progress to is_animating

This commit is contained in:
Héctor Ramón Jiménez 2025-01-28 03:04:31 +01:00
parent 086b06553b
commit 23d42d2827
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 30 additions and 27 deletions

View file

@ -81,7 +81,7 @@ where
/// Returns true if the [`Animation`] is currently in progress.
///
/// An [`Animation`] is in progress when it is transitioning to a different state.
pub fn in_progress(&self, at: Instant) -> bool {
pub fn is_animating(&self, at: Instant) -> bool {
self.raw.in_progress(at)
}

View file

@ -103,18 +103,7 @@ impl Gallery {
Task::none()
}
Message::ThumbnailDownloaded(id, Ok(rgba)) => {
let thumbnail = Thumbnail {
handle: image::Handle::from_rgba(
rgba.width,
rgba.height,
rgba.pixels,
),
fade_in: Animation::new(false).slow().go(true),
zoom: Animation::new(false)
.quick()
.easing(animation::Easing::EaseInOut),
};
let thumbnail = Thumbnail::new(rgba);
let _ = self.thumbnails.insert(id, thumbnail);
Task::none()
@ -179,18 +168,6 @@ impl Gallery {
}
}
struct Thumbnail {
handle: image::Handle,
fade_in: Animation<bool>,
zoom: Animation<bool>,
}
impl Thumbnail {
fn is_animating(&self, now: Instant) -> bool {
self.fade_in.in_progress(now) || self.zoom.in_progress(now)
}
}
fn card<'a>(
metadata: &'a Image,
thumbnail: Option<&'a Thumbnail>,
@ -230,6 +207,32 @@ fn card<'a>(
}
}
struct Thumbnail {
handle: image::Handle,
fade_in: Animation<bool>,
zoom: Animation<bool>,
}
impl Thumbnail {
fn new(rgba: Rgba) -> Self {
Self {
handle: image::Handle::from_rgba(
rgba.width,
rgba.height,
rgba.pixels,
),
fade_in: Animation::new(false).slow().go(true),
zoom: Animation::new(false)
.quick()
.easing(animation::Easing::EaseInOut),
}
}
fn is_animating(&self, now: Instant) -> bool {
self.fade_in.is_animating(now) || self.zoom.is_animating(now)
}
}
struct Viewer {
image: Option<image::Handle>,
background_fade_in: Animation<bool>,
@ -270,8 +273,8 @@ impl Viewer {
}
fn is_animating(&self, now: Instant) -> bool {
self.background_fade_in.in_progress(now)
|| self.image_fade_in.in_progress(now)
self.background_fade_in.is_animating(now)
|| self.image_fade_in.is_animating(now)
}
fn view(&self, now: Instant) -> Element<'_, Message> {