【发布时间】:2014-04-10 20:04:37
【问题描述】:
我遇到了画布问题。我实现了一个在 Canvas 元素(实际上是网格)中拖放图像的解决方案。图像一旦被丢弃,就无法重新拖动,这限制了解决方案的灵活性。我漏了一句吗?
function dragDrop(e,ui){
// get the drop point (be sure to adjust for border)
var x=parseInt(ui.offset.left-offsetX)-1;
var y=parseInt(ui.offset.top-offsetY);
// get the drop payload (here the payload is the $tools index)
var theIndex=ui.draggable.data("toolsIndex");
// drawImage at the drop point using the dropped image
ctx.drawImage($tools[theIndex],x,y,32,32);
}
【问题讨论】:
标签: canvas drag-and-drop