在画布中拖动对象 [英] Drag objects in canvas
问题描述
我正在寻找一种易于使用的方法来分配拖拽行为到画布中的多个对象(图像,形状等)。有没有人有一个好的方法或知道任何图书馆拖动对象?感谢
创建自己的鼠标事件需要一些工作 - 最好是创建或使用某种微型库。我想在不久的将来创造这样的东西。无论如何,我在jsFiddle上创建了一个拖放演示,演示如何拖动图片 - 您可以在此处查看。 p>
您可以创建如下所示的可拖动图像:
var myImage = new DragImage (sourcePath,x,y);
如果您对此有任何疑问,请与我们联系。希望它有帮助。
编辑
拖动多个图片时出现错误。 这是新版本。
另一件你可能想检出的是 easeljs 它的风格AS3 ... mouseEvents拖动等...
Im looking for an easy to use method of assigning drag behavior to multiple objects (images, shapes etc) in canvas. Does anyone have a good way or know of any libraries for dragging objects around? Thanks
Creating your own mouse events takes a little work - ideally you should either create or use some kind of mini-library. I'm thinking of creating something like this in the near future. Anyway, I created a drag and drop demo on jsFiddle showing how to drag images - you can view it here.
You can create draggable images like this:
var myImage = new DragImage(sourcePath, x, y);
Let me know if you have any questions about this. Hope it helps.
EDIT
There was a bug when dragging multiple images. Here is a new version.
Another thing you might want to check out is easeljs it sort of in the style of AS3... mouseEvents dragging etc...
这篇关于在画布中拖动对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!