Created
April 15, 2023 01:57
-
-
Save nienow/34d17cb88ad60d5ffa183430502b7938 to your computer and use it in GitHub Desktop.
DragDrop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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