javascript - Multiple Drag Drop multiple elements into canvas element
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.
相关阅读排行
- 1利用javascript和canvas获取UIWebView网页里的图片(不用再下载)
- 2简单HTML5 Canvas Arrow旋转动画
- 3javascript 导出div为图片PNG,div转svg,svg转canvas
- 4用Javascript实现让Canvas变模糊的效果
- 5JavaScript基础——使用Canvas画图