JSFiddle - React, Tailwind, and code Playground
HTML
<div id="wrapper">
<div id="left">
<ul id="ul-left">
<li>ONE-left</li>
<li>TWO-left</li>
<li>THREE-left</li>
</ul>
</div>
<div id="right">
<ul id="ul-right">
</ul>
</div>
</div>
CSS
#wrapper {
width: 450px;
border: 1px solid #333;
padding:10px;
height:150px;
margin: 30% auto;
text-align:center;
}
#left {
width:205px;
float:left;
border:1px solid #666;
height:150px;
overflow-y: scroll;
}
#ul-left li {
background-color: #FFD;
border:1px solid white;
padding:2px;
text-align:center;
}
#right {
width:205px;
float:right;
border:1px solid #666;
height: 150px;
overflow-y:scroll;
}
#ul-right li {
background-color: #FFD;
border:1px solid white;
padding:2px;
text-align:center;
}
JavaScript
$(document).ready(function() {
$('#ul-left li').click(function() {
if ($(this).is('.selected')){
$(this).removeClass('selected').css({'background-color':'#FFD'});
} else {
$(this).addClass('selected').css({'background-color':'#FFA'});
}
});
//Sortable config
$('#ul-right').sortable({
cursor:'move',
helper:'clone',
scroll:false,
stop:function (e, ui) {
},
zIndex:200
}).disableSelection();
//Draggable Config
$('#ul-left li').draggable({
disabled:false,
connectToSortable:'#ul-right',
cursor:'move',
helper:function (e, ui) {
var selected = $('#ul-left .selected');
if (selected.length === 0) {
selected = $(this);
}
var container = $('<div></div>').attr('id', 'draggingContainer');
container.append(selected.clone());
return container;
},
scroll:false,
zIndex:200,
start:function (e, ui) {
},
drag:function (e, ui) {
},
stop:function (e, ui) {
$('#wrapper ul li').removeClass('selected').css({'background-color':'#FFD'});
$('#ul-right').append(ui.helper.children());
}
});
});