JSFiddle - React, Tailwind, and code Playground
HTML
<ul id="ordename">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
<li>Item 8</li>
<li>Item 9</li>
</ul>
CSS
ul,li{margin:0;padding:0; width:300px;}
li{border:solid 1px #000;}
JavaScript
var orden;
window.onload=function(){
orden=new Draglist('ordename',true);
}
var Draglist=function(target,identificar){
var _this = this;
this.target=document.getElementById(target);
this.target.onselectstart=new Function ("return false")
this.tgt=target;
this.lastover='';
this.encambio=false;
this.flying=null;
this.items = this.target.getElementsByTagName("li");
for(x=0;x<this.items.length;x++){
this.items[x].className=this.tgt;
if(identificar==true){this.items[x].id=x;}
this.items[x].onmousedown=function(e){drag(e);}
window.onmouseup=function(e){drop(e)}
this.items[x].onmouseout=function(e){out(e);}
}
function out(e){
if(_this.flying!=null){
this.off1= document.createElement("li");
this.off1.id= 'comod';
e.toElement.onmouseout=null;
_this.target.replaceChild(this.off1,e.fromElement);
_this.target.replaceChild(e.fromElement,e.toElement)
_this.target.replaceChild(e.toElement,document.getElementById('comod'));
//e.toElement.onmouseout='';*Aqui es donde quiero devolver*
}
}
function drag(e){
if(e.target.className==_this.tgt){
_this.flying=e.target;
e.target.style.opacity='0.5';
}
}
function drop(e){
if(_this.flying!=null){_this.flying.style.opacity='1';}
_this.flying=null;
}
}