在fiddle中,将图像拖放到容器中...我希望工具栏中的画布对象可拖动并可放入容器中。我可以这样做吗?请帮助我......
JS代码:
var layer = new Kinetic.Layer();
stage.add(layer);
var image1 = new Image();
image1.onload = function () {
$house.show();
}
image1.src = "https://dl.dropboxusercontent.com/u/139992952/stackoverflow/house32x32transparent.png";
$house.draggable({
helper: 'clone',
});
$house.data("url", "house.png");
$house.data("width", "32");
$house.data("height", "33");
$house.data("image", image1);
$stageContainer.droppable({
drop: dragDrop,
});
function dragDrop(e, ui) {
var x = parseInt(ui.offset.left - offsetX);
var y = parseInt(ui.offset.top - offsetY);
var element = ui.draggable;
var data = element.data("url");
var theImage = element.data("image");
var image = new Kinetic.Image({
name: data,
x: x,
y: y,
image: theImage,
draggable: true
});