I'm thinking of making a dashboard using the Drag and Drop features of HTML.
Example taken from w3schools
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("text", ev.target.id);
}
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(data));
}
div {
width: 50px;
height: 50px;
padding: 10px;
border: 1px solid #aaaaaa;
}
<html>
<head></head>
<body>
<p>Arraste para o retângulo:</p>
<div ondrop="drop(event)" ondragover="allowDrop(event)"></div>
<img id="drag1" src="https://i.stack.imgur.com/uwI5h.png?s=48&g=1"draggable="true" ondragstart="drag(event)" width="50" height="50">
</body>
</html>
I'd like to know how I can make this feature work when it's opened on a mobile (or another touchscreen), because the click is different:
- If I touch and release, it would be a click
- If I tap and hold, open the options