#dioxus #events #interaction #gesture

dioxus-use-gesture

Dioxus的手势交互库

1个不稳定版本

0.1.0 2023年10月16日

#9#gesture

MIT/Apache

9MB
2K SLoC

JavaScript 1.5K SLoC // 0.0% comments Rust 140 SLoC

dioxus-use-gesture

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

let drag_ref = use_drag(cx, 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| {
        spring_ref.mount(event.data.clone());
        drag_ref.mount(event.data);
    }
})

依赖项

~15MB
~282K SLoC