是否可以在
JavaScript中更改事件的类型?
在这种情况下,我在画布上使用jQuery触发事件,但在渲染此画布的特定元素上,如绘制的形状或图像.
mousemoveevent ---> [canvas] -> [find element] ---> mousemoveoverelementevent
基本上我在整个画布上捕获onmousemove事件:
$('canvas').bind('mousemove'........
但是画布中不存在DOM,因此我希望它能够转换(以便在后面的过程中进行聊天):
$('canvas').bind('mousemoveOverElement'........ $('canvas').bind('mouseenterOnElement'........ $('canvas').bind('mouseleaveOnElement'........
然后分配类似的东西
e.element = 'imageAtACertainPositionInTheCanvas'
我更喜欢传递修改后的事件而不是分配新的回调.
解决方法
>
CanvasScript3提供具有某些功能(如活动)的图书馆.
MouseOver活动,MouseOut活动有一些事情.检查
list of tests.
>在以前的 stackoverflow questions中还有将事件与Canvas“元素”相关联的示例.
> HTML5 Canvas Rectangular Region Mouseover Tutorial
>在以前的 stackoverflow questions中还有将事件与Canvas“元素”相关联的示例.
> HTML5 Canvas Rectangular Region Mouseover Tutorial
您可能想要阅读Sprite and Canvas的问题及其相对糟糕的表现.