JSFiddle - React, Tailwind, and code Playground
HTML
<h1>Drag Handle</h1>
<div id="draggable">
<div id="handle">
</div>
<textarea>This text is selectable</textarea>
</div>
CSS
#draggable {
width: 100px;
height: 100px;
border: 1px solid black;
display: flex;
flex-direction: column;
}
#handle {
width: 0;
height: 0;
border-right: 20px solid transparent;
border-top: 20px solid black;
cursor: move;
}
textarea {
flex-grow: 1;
}
JavaScript
var draggable = document.getElementById('draggable');
var handle = document.getElementById('handle');
var target = false;
handle.onmousedown = function(e) {
e.target.parentNode.setAttribute('draggable', 'true')
};
handle.onmouseup = function(e) {
e.target.parentNode.setAttribute('draggable', 'false')
};
draggable.ondragstart = function(e) {
e.dataTransfer.setData('text/plain', 'handle');
};
draggable.ondragend = function(e) {
e.target.setAttribute('draggable', 'false')
};