The setup has a few issues which I'm trying to solve, been at it for a while now. Basically, I've made it sortable so you can move items to another folder. But as you might not have every folder open (not shown in jsfiddle) it is setup to use a hover class, but when dragging a file and it starts sorting, the hover class still sometimes shows even though I'm not hovering over a folder...
Also after sorting a file, trying to drag it around again makes it glitch up and makes it so you cant really move it again for some reason.
https://jsfiddle.net/4Lz5Lfsj/12/
HTML:
<main>
<div id="menu">
<ul id="menuul">
<li class="folder">Folder</li>
<li class="folder">Folder</li>
<li class="folder">Folder</li>
<ul>
<li class="clippet">File</li>
<li class="clippet">File</li>
</ul>
<li class="clippet">File</li>
<li class="clippet">File</li>
<li class="clippet">File</li>
<li class="clippet">File</li>
</ul>
</div>
</main>
CSS:
main
{
display: inline-block;
border: 1px solid black;
padding-right: 12px;
}
#menu ul li
{
display: flex;
}
#menu ul li p
{
display: inline-block;
margin: 0;
margin-left: 8px;
}
.draggableHover
{
background-color: grey;
}
JS:
$(".clippet").draggable({
revert: "invalid",
scroll: false,
delay: 300,
cursorAt: { left: -5 },
cursor: 'move',
connectToSortable: '#menuul'
});
$(".folder").droppable({
accept: ".clippet",
hoverClass: 'draggableHover'
});
$("#menuul").sortable(
{
revert: true,
handle: 'p'
});