dioxus/examples/_examples/anim.rs

50 lines
1.2 KiB
Rust
Raw Normal View History

2021-07-01 18:14:59 +00:00
fn main() {
// render the
let transition = move |cx, (width, height)| {};
cx.render(rsx! {
div {
Transition {
start: (0, 5),
stop: (10, 10),
render: transition
}
Transition {
start: (0, 5),
stop: (10, 10),
render: move |cx, (width, height)| {
//
cx.render(rsx!{
div {
style {
width: width,
width: height
}
}
})
}
}
}
})
}
2021-07-01 20:03:27 +00:00
// Animations with signals
2021-07-01 18:14:59 +00:00
fn signal_based(cx: ()) {
const InitPos: (i32, i32) = (0, 0);
const EndPos: (i32, i32) = (100, 200);
let spring = use_spring(cx, move |spring| spring.from(InitPos).to(EndPos));
cx.render(rsx! {
div {
2021-07-01 20:03:27 +00:00
style: [
2021-07-01 18:14:59 +00:00
width: spring.0,
2021-07-01 20:03:27 +00:00
height: spring.1
]
button { onclick: move |_| spring.set(InitPos), "Reset" }
button { onclick: move |_| spring.set(EndPos), "Animate" }
2021-07-01 18:14:59 +00:00
}
})
}