JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://jqueryui.com/themes/base/jquery.ui.all.css">
<link rel="stylesheet" href="http://jqueryui.com/demos/demos.css">
<div id="message"></div>
<br style="clear:both"/>
<div class="demo">
<div id="draggable" class="ui-widget-content">
<p>Drag me to my target</p>
</div>
<div id="droppable" class="ui-widget-header">
<p>Drop here</p>
</div>
</div><!-- End demo -->
<div style="display: none;" class="demo-description">
<p>Enable any DOM element to be droppable, a target for draggable elements.</p>
</div><!-- End demo-description -->
<br style="clear:both"/>
<input type="button" id="btnMove" value="Drop"/>
CSS
#draggable { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0;background-color:red; }
#droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; background-color:blue;}
JavaScript
$(function() {
$( "#draggable" ).draggable();
$( "#droppable" ).droppable({
drop: function( event, ui ) {
layerDrop();
}
});
$("#btnMove").click(function()
{
$("#draggable").animate({"left": $( "#droppable" ).offset().left ,"top": $( "#droppable" ).offset().top},
{
duration: 1000, specialEasing: { width: 'linear' },
complete:function()
{
$("#message").html("Completed!");
layerDrop();
//whatever
}
}
);
});
function layerDrop(){
$( "#droppable")
.addClass( "ui-state-highlight" )
.find( "p" )
.html( "Dropped!" );
}
});