javascript - Roll hover image -


i searched on internet lot couldn't find useful link. trying develop custom menu.

it needs area-based rollover menu changes depending on part of image being hovered on user. image , related link needs change depending on area of image user hovering over. check below image: close box

after clicking next image below one, open box

lastly when hover on specific slice of pizza, image should changed accordingly. example below image:

enter image description here

is possible css3, javascript?

there's 2 different ways think of. since tagged jquery i'm assuming that's acceptable. pagex , pagey track mouse movements on screen , can used determine area of screen being hovered over. here's fiddle made determine coordinates: http://jsfiddle.net/cpk3mqxw/

$("#image").mousemove(function (e) { mousex = e.pagex; mousey = e.pagey; $("#update").text("x: " + mousex + " y:" + mousey); }); 

edit: checking coordinates, need think of page grid system, per usual javascript, , gauge if mousex more 132 , less 155 must on part of image. again, separate span tag updated x , y coordinates helpful. a.e:

if(mouse x >= 102 && mousex <= 220 && mousey >= 26) { //do } 

it pays off in end, quite bit of work. way use image map.

<img src="image.jpg" id="image1" usemap="#one"> <map name="one"> <area coords="30, 50, 70, 100" href="gohere.html"> </map> 

and if you'd area highlighted or styled can use maphilight.js can find more information on here: http://davidlynch.org/blog/2008/03/maphilight-image-map-mouseover-highlighting/


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -