Rename Animation::in_progress to is_animating
This commit is contained in:
parent
086b06553b
commit
23d42d2827
2 changed files with 30 additions and 27 deletions
|
|
@ -81,7 +81,7 @@ where
|
||||||
/// Returns true if the [`Animation`] is currently in progress.
|
/// Returns true if the [`Animation`] is currently in progress.
|
||||||
///
|
///
|
||||||
/// An [`Animation`] is in progress when it is transitioning to a different state.
|
/// 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)
|
self.raw.in_progress(at)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,18 +103,7 @@ impl Gallery {
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
Message::ThumbnailDownloaded(id, Ok(rgba)) => {
|
Message::ThumbnailDownloaded(id, Ok(rgba)) => {
|
||||||
let thumbnail = Thumbnail {
|
let thumbnail = Thumbnail::new(rgba);
|
||||||
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 _ = self.thumbnails.insert(id, thumbnail);
|
let _ = self.thumbnails.insert(id, thumbnail);
|
||||||
|
|
||||||
Task::none()
|
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>(
|
fn card<'a>(
|
||||||
metadata: &'a Image,
|
metadata: &'a Image,
|
||||||
thumbnail: Option<&'a Thumbnail>,
|
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 {
|
struct Viewer {
|
||||||
image: Option<image::Handle>,
|
image: Option<image::Handle>,
|
||||||
background_fade_in: Animation<bool>,
|
background_fade_in: Animation<bool>,
|
||||||
|
|
@ -270,8 +273,8 @@ impl Viewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_animating(&self, now: Instant) -> bool {
|
fn is_animating(&self, now: Instant) -> bool {
|
||||||
self.background_fade_in.in_progress(now)
|
self.background_fade_in.is_animating(now)
|
||||||
|| self.image_fade_in.in_progress(now)
|
|| self.image_fade_in.is_animating(now)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view(&self, now: Instant) -> Element<'_, Message> {
|
fn view(&self, now: Instant) -> Element<'_, Message> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue