Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hover only on non-transparent part of image

Is there any way to make only a non-transparent portion of an image to trigger mouse-over event?

If the mouse travels to the transparent area, the mouse-out should be triggered and the script should listen for any mouse-over event on a layer underneath the image.

Is it possible? Thanks for any input.

Edit: I am looking to do this without using flash.

like image 995
Nirmal Avatar asked Apr 22 '10 08:04

Nirmal


2 Answers

You can use an image with the old-fashioned <map> and <area> tags. An area tag can trigger javascript mouse events (an example use is this jQuery plugin: jQuery maphilight).
However, there is no good way to create the map dynamically - you'll have to do it manually, or call a server-side service to map it.

like image 145
Kobi Avatar answered Sep 21 '22 16:09

Kobi


ImageMapster looks to be a good easy way to get image area maps working cross browser (IE6+, requires jQuery).

Another option would be to use raphael.js which creates SVG vector images that are translated to work in everything from IE6 upwards (everything except the stock browser in some old Android phones, I believe). They can be controlled using javascript in all sorts of ways and can have all the standard events e.g. mouseover, click, etc.

Raphael works better here than the Flash option in that it doesn't rely on Flash. It's less simple than the area map option and has a steep learning curve, but, for complex cases and dynamically changing shapes, it brings the additional benefit of a wide range of ways to control the vector images you create.

like image 27
user56reinstatemonica8 Avatar answered Sep 23 '22 16:09

user56reinstatemonica8