为什么 DragOver/Enter 事件需要 Canvas 上的背景?
我有一块画布,我想在上面接受拖动。
我已向画布添加了 DragOver 和 DragEnter 事件侦听器,但它们仅在我拖动画布内的某些内容(另一个子元素)时才起作用。
我意识到,如果我将画布的背景颜色设置为黑色,它就可以工作。因此,我将其背景透明度设置为 0,这有效...购买是否有更好的方法来解决画布明显需要在其内部包含某些内容来接受拖动事件的问题。
谢谢罗布
I have a canvas which I want to accept drags on.
I have added a dragOver and dragEnter event listeners to the canvas, but they only work if I drag over something inside the canvas (another child element).
I realised that if I set the canvas' background colour to black it works. So I have set it's background transparency to 0, which works... buy is there a better way to work around this apparent need for the canvas to have something inside it to accept dragEvents.
Thanks
Rob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据一位 Flex 开发人员介绍,“在 Flash 中,透明像素和 Sprite 中根本没有绘制过的区域之间是有区别的。” (http://www.mail-archive.com/[email protected]/msg127690.html)
我猜这就是您需要透明背景的原因。无论如何,这始终是我解决这个问题的方式。还有这个问题< /a> 讨论了这个问题。
希望这有帮助!
According to one of the Flex developers, "In Flash there is a difference between a transparent pixel and an area in a Sprite that hasn't been drawn on at all." (http://www.mail-archive.com/[email protected]/msg127690.html)
I'm guessing this is the reason why you need to have the transparent background. For what it's worth, this is always the way I've seen this problem solved. There is also this question which talks about this problem.
Hope this helps!