Irregular anchors and shapes using JS in HTML/HTML5

a 夏天 提交于 2020-01-04 07:03:56

问题


Is it possible to have irregular shapes like anchors on some surface in JS that can be clickable and it becomes a ball on runtime on page loads? I want to animate that surface that can be a ball and also want to track that which anchor shape is at particular point.

So is it possible using JS? How can this be achieved? I was unable to find any solution. Is there some JS library that can do this? Something like processing.js or Raphael js?


回答1:


I suggest using SVG with excelent Raphael js library. You can make interactive animations with pure javascript (i.e. without additional plugins) and those objects can be made irregular anchors (overriding click, mouseover and mouseout events to emulate anchor behaviour).

Another idea is to use HTML5 canvas, but this requires more code (the technology is still immature) and may fail to work under different browsers.




回答2:


Could I suggest an HTML image map? You can embed an IMG tag in the page set it's usemap attribute and then define shapes on that image to be clickable areas.

It doesn't have as many features as a canvas but maybe a regular IMG element will do in this case.



来源:https://stackoverflow.com/questions/7693159/irregular-anchors-and-shapes-using-js-in-html-html5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!