JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://greenethumb.com/github/jquery-free-transform/css/jquery.freetrans.css">
<script src="http://greenethumb.com/github/jquery-free-transform/js/Matrix.js"></script>
<script src="http://greenethumb.com/github/jquery-free-transform/js/jquery.freetrans.js"></script>
<body>
<div class="dragImg"><img class="img" src="http://www.thumbshots.com/Portals/0/Images/Feature%20TS%201.jpg">
</div>
<div id="dropHere"></div>
</body>
CSS
#dropHere {
width:400px;
height: 400px;
border: dotted 1px black;
}
.trans{
width:100px;
}
JavaScript
$('.trans').freetrans();
$(function(){
//Make every clone image unique.
var counts = [0];
$(".dragImg").draggable({
helper: "clone",
//Create counter
start: function() { counts[0]++; }
});
$("#dropHere").droppable({
drop: function(e, ui){
if(ui.draggable.hasClass("dragImg")) {
$(this).append($(ui.helper).clone());
//Pointing to the dragImg class in dropHere and add new class.
$("#dropHere .dragImg").addClass("item-"+counts[0]);
$("#dropHere .img").addClass("imgSize-"+counts[0]);
//Remove the current class (ui-draggable and dragImg)
$("#dropHere .item-"+counts[0]).removeClass("dragImg ui-draggable ui-draggable-dragging");
$(".item-"+counts[0]).dblclick(function() {
$(this).remove();
});
make_draggable($(".item-"+counts[0]));
$(".imgSize-"+counts[0]).mousedown(function() {
$(event.target).freetrans();
});
//this doesn't work...
//$(".imgSize-"+counts[0]).mousedown(function() {
//$(event.target).freetrans('controls', false);
//});
}
}
});
var zIndex = 0;
function make_draggable(elements)
{
elements.draggable({
containment:'parent',
start:function(e,ui){ ui.helper.css('z-index',++zIndex); },
stop:function(e,ui){
}
});
}
});