ITKeyword,专注技术干货聚合推荐

注册 | 登录

javascript - Multiple Drag Drop multiple elements into canvas element

itPublisher 分享于

2021腾讯云限时秒杀,爆款1核2G云服务器298元/3年!(领取2860元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1062

2021阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址https://www.aliyun.com/minisite/goods

Part of my project is drag and dropping multiple images from a div element into a canvas, the images are of .svg type and im using the library fabric.js to render those images. The problem im facing is that the file doesnt get dropped into the canvas more than once.

Alerting at each level shows that the function drop is called only once despite the drag function being called twice.

Here's the part of the javascript code:

var object = new Image();

function allowDrop(ev)
{
    ev.preventDefault();
}

function drag(ev)
{
    ev.dataTransfer.setData("Text",ev.target.id);
}

function drop(ev)
{
    ev.preventDefault();
    var data=document.getElementById(ev.dataTransfer.getData("Text")).getAttribute('src');
    object.src = data.toString();
main();

}

main() is the function where the url of images are caught using object.src and then are rendered using fabric.js library

javascript html5 canvas drag-and-drop fabricjs
|
  this question
asked Sep 30 '12 at 20:45 firecast 190 2 2 17

 | 

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.


相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。