Function yew_hooks::use_drag_with_options
source · [−]pub fn use_drag_with_options(
node: NodeRef,
options: UseDragOptions
) -> UseDragHandleExpand description
This hook tracks file, link and copy-paste drags.
use_drag hook with options.
Example
use yew_hooks::{use_drag_with_options, UseDragOptions};
#[function_component(UseDrag)]
fn drag() -> Html {
let node = use_node_ref();
let state = use_drag_with_options(node.clone(), UseDragOptions {
ondragstart: Some(Box::new(move |e| {
if let Some(data_transfer) = e.data_transfer() {
let _ = data_transfer.set_data("text", "hello");
}
})),
ondragend: Some(Box::new(move |e| {
})),
});
html! {
<div ref={node}>
<p>
<b>{ " Dragging: " }</b>
{ *state.dragging }
</p>
<p>
{ "Try to drag this area" }
</p>
</div>
}
}