开发者

HTML5 canvas object events [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Closed 4 years ago. Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.

Is开发者_如何学Python there a way to attach an event handler to a object drawn on HTML5 Canvas, without tracking the points?


Try Kinetic JS

http://www.html5canvastutorials.com/advanced/html5-canvas-path-mouseover/


You might also take a look at KineticJS - it was designed to make attaching event listeners to shapes on the screen as simple as possible while sticking to Canvas API patterns. You can check out an example here:

http://www.html5canvastutorials.com/advanced/html5-canvas-path-mouseover/


Take a look at Cake. It's a scene graph plug-in for canvas elements. You should be able to attach event handlers to canvas objects with it.


I think the answer is (but no other poster is using the term) that there is no first-class support for events on graphic primitives drawn on HTML5 canvas. That is not to say that it is not possible to write a listener, merely that if you want to do that you have to use an API like Kinetic JS as can be seen at

http://www.html5canvastutorials.com/advanced/html5-canvas-path-mouseover/


I think, KineticJS should suffice for most of your needs. But make sure that you keep HTML5 originated events away from KineticJS events. I am facing some issues on these lines. will update you if I find something. Regards

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜