I'm making a playlist for demonstration purposes. I have set up a unordered list nested with list items. These items have been made draggable by the "draggable=true" handler, which works great.
Here's where I'm stuck;
Once the item has been clicked, and ready to drag. I need the user to have a strong visual feedback on where the user is dropping the item. The standardisation doesn't give any visual feedback, is simply puts the list item between the others. I'm looking for way to either visually push the other list elements aside, or at the very least a highlighted border on the location the user is holding the dragged item.
What's the best way to go about this? I put in some code here just in case, but what I'm looking for is outside of the code I've written.
HTML:
<ul>
<li draggable="true" ondragstart="dragStarted(event)" ondragover="draggingOver(event)" ondrop="dropped(event)" ondragenter="dragEnter(event)">
Item 1
</li>
<li draggable="true" ondragstart="dragStarted(event)" ondragover="draggingOver(event)" ondrop="dropped(event)" ondragenter="dragEnter(event)">
Item 2
</li>
<li draggable="true" ondragstart="dragStarted(event)" ondragover="draggingOver(event)" ondrop="dropped(event)" ondragenter="dragEnter(event)">
Item 3
</li>
</ul>
JS
var source;
function dragStarted(e){
source = e.target;
e.dataTransfer.setData("text/plain", e.target.innerHTML);
e.dataTransfer.effectAllowed = "move";
}
function draggingOver(e){
e.preventDefault();
e.dataTransfer.dropEffect = "move";
}
function dropped(e){
e.preventDefault();
e.stopPropagation();
if (e.target.localName === 'li') {
source.innerHTML = e.target.innerHTML;
e.target.innerHTML = e.dataTransfer.getData("text/plain");
}
}
How do I add code that will allow me to design visual feedback in the form of a highlighted border between the items.