use super::{AnimationHandle, AnimationPlaybackState};
use crate::{
AnimationTargetId, property::PropertySnapshot, runtime::entry::ActiveAnimation,
timing::Duration,
};
#[derive(Debug, Clone, PartialEq)]
pub struct AnimationRegistration {
target: AnimationTargetId,
handle: AnimationHandle,
state: AnimationPlaybackState,
properties: Option<PropertySnapshot>,
completed_at: Option<Duration>,
}
impl AnimationRegistration {
pub(super) fn from_entry(entry: &ActiveAnimation) -> Self {
Self {
target: entry.target(),
handle: entry.handle(),
state: entry.state(),
properties: entry.last_snapshot().cloned(),
completed_at: entry.completed_at(),
}
}
#[must_use]
pub const fn handle(&self) -> AnimationHandle {
self.handle
}
#[must_use]
pub const fn state(&self) -> AnimationPlaybackState {
self.state
}
#[must_use]
pub const fn properties(&self) -> Option<&PropertySnapshot> {
self.properties.as_ref()
}
#[must_use]
pub const fn completed_at(&self) -> Option<Duration> {
self.completed_at
}
}