Results 1 to 1 of 1
Feb 25, 2011, 10:21 #1
- Join Date
- Jan 2010
- 0 Post(s)
- 0 Thread(s)
Detecting area-element (imagemap) with touchmove/mousemove
I have some difficulties with touchmove and an imagemap.
I have an imagemap (this is important).
The user can drag his finger or mouse over the image.
I user mousemove/touchmove.
If the user moves over an area of the imagemap, I want to doSomething.
I want it to work on the Desktop and on the iPad (at least).
On the desktop I can use the event.target of mousemove to check whether the mouse is over a certain area.
Unfortunately that does not work with touchmove because the event.target of touchmove is always the original target when the touch started.
As a workaround I got the position of the finger/mouse with event.clientX and
checked for the target element (the finger is over) with elementFromPoint. That works fine on the iPad. It also seems to work on the Desktop Browsers with other elements than area.
But it does not work for area elements with firefox and Opera (not sure about IE9). On those browsers I get the image (that uses the imagemap) as target element.
I would think that elementFromPoint should also give an area element if you hit it with the right coordinates. So is this a bug?
I made a switch now to handle both scenarios. I think it will work (I am not completely finished yet).
Did I overlook something?
Is this the best way to do this?
Any other ideas or comments?
I have not tested on other touch devices than the iPad.