Skip to content

Instantly share code, notes, and snippets.

@nienow
Created April 15, 2023 01:57
Show Gist options
  • Save nienow/34d17cb88ad60d5ffa183430502b7938 to your computer and use it in GitHub Desktop.
Save nienow/34d17cb88ad60d5ffa183430502b7938 to your computer and use it in GitHub Desktop.
DragDrop
const DragDropComp = () => {
const onDragStart = (e) => {
const clone = e.target.cloneNode(true);
e.dataTransfer.setDragImage(clone, 0, 0);
};
const onDragOver = (e) => {
// if is droppable
e.preventDefault();
};
const onDrop = () => {
// do something
};
return <div>
<div draggable={true} onDragStart={onDragStart}>Draggable</div>
<div onDragOver={onDragOver} onDrop={onDrop}>Drop Here</div>
</div>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment