Function dioxus_spring::use_spring_style
source · pub fn use_spring_style<T, V>(
cx: Scope<'_, T>,
from: V,
make_style: impl FnMut(V) -> String + 'static
) -> &UseSpringStyle<V>where
V: Lerp<Scalar = f32> + Clone + 'static,Examples found in repository?
examples/app.rs (lines 7-9)
6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn app(cx: Scope) -> Element {
let spring_ref = use_spring_style(cx, 1f32, |scale| {
format!("transform-origin: top left; transform: scale({scale});")
});
render!(
h1 {
onmounted: move |event| spring_ref.mount(event.data),
onmouseenter: move |_| spring_ref.animate(2., Duration::from_secs(1)),
onmouseleave: move |_| spring_ref.animate(1., Duration::from_secs(1)),
"Hover me!"
}
)
}