Skip to main content

ferroui_base/animation/
animator_transition_observable.rs

1use crate::animation::easings::Easing;
2use crate::animation::TransitionObservableBase;
3use crate::reactive::IObservable;
4use std::rc::Rc;
5
6/// Transition observable based on an animator's interpolation: produces
7/// the values between `old_value` and `new_value`.
8pub struct AnimatorTransitionObservable;
9
10impl AnimatorTransitionObservable {
11    pub fn create<T: 'static>(
12        interpolate: impl Fn(f64, &T, &T) -> T + 'static,
13        progress: Rc<dyn IObservable<f64>>,
14        easing: Easing,
15        old_value: T,
16        new_value: T,
17    ) -> Rc<dyn IObservable<T>> {
18        TransitionObservableBase::new(progress, easing, move |progress| {
19            interpolate(progress, &old_value, &new_value)
20        })
21    }
22}