Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 1.41 KB

README.md

File metadata and controls

44 lines (35 loc) · 1.41 KB

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_mounted();

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

use_drag(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)),
});

rsx!(div {
    onmounted: move |event| element_ref.onmounted(event)
})