How can you tell if your cursor is over a certain element in Raphael.js?
if(mouse_is_over){
//do this
}
else{
//do this
}
Ideally, I would like to test if the mouse if over a circle I named ‘c’.
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would strongly recommend using Raphael’s Element.data method to associate your private, circle-specific data with each item, and then acting on or against that data in a hover handler (manually detecting intersection with getElementByPoint may be expensive in a mouseover handler). You can store anything with
data:At this point, the game becomes very easy. Whether you use Raphael’s built in hover handling…
…or a mouseover event powered, for instance, by jQuery…
…the logic is the same. Simply query the application data you’ve associated with your elements and do your thing.
I happened to already have a terrible little script that animates circles at random locations, and I retrofitted it to accommodate your scenario.