#dioxus #interaction #gesture #dioxus-spring

dioxus-use-gesture

Gesture interaction library for Dioxus

2 unstable releases

0.2.0-alpha.1 Oct 27, 2024
0.1.0 Oct 16, 2023

#3 in #gesture

Download history 2/week @ 2024-07-29 2/week @ 2024-09-23 29/week @ 2024-10-21 69/week @ 2024-10-28 13/week @ 2024-11-04

111 downloads per month

MIT/Apache

22KB
90 lines

Dioxus use_gesture

Crates.io version docs.rs docs CI status

Gesture interaction library for Dioxus.

Pairs great with dioxus-spring!

let element_ref = use_signal(cx, || None);

let (spring_ref, value_ref) = use_spring_signal(cx, [0f32, 0f32]);
use_animated(cx, element_ref, value_ref, |[x, y]| {
    format!("width: 200px; height: 200px; background: red; transform: translate({x}px, {y}px);")
});

use_drag(cx, element_ref, move |state, x, y| match state {
    DragState::Move => spring_ref.set([x, y]),
    DragState::End => spring_ref.animate([0., 0.], Duration::from_millis(500)),
});

render!(div {
    onmounted: move |event| element_ref.set(Some(event.data.clone()))
})

Dependencies

~18–27MB
~394K SLoC