Function use_drag

Source
pub fn use_drag<'hook>(
    node: NodeRef,
) -> impl 'hook + Hook<Output = UseDragHandle>
Expand description

This hook tracks file, link and copy-paste drags.

§Example

use yew_hooks::prelude::*;

#[function_component(UseDrag)]
fn drag() -> Html {
    let node = use_node_ref();
    let state = use_drag(node.clone());

    html! {
        <div ref={node}>
            <p>
                <b>{ " Dragging: " }</b>
                { *state.dragging }
            </p>
            <p>
                { "Try to drag this area" }
            </p>
        </div>
    }
}

§Note

When used in function components and hooks, this hook is equivalent to:

pub fn use_drag(node: NodeRef) -> UseDragHandle {
    /* implementation omitted */
}