Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8698301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:42:02+00:00 2026-06-13T01:42:02+00:00

How can you tell if your cursor is over a certain element in Raphael.js?

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:42:03+00:00Added an answer on June 13, 2026 at 1:42 am

    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:

    var circle = paper.circle( ... );
    circle.data( 'name', "My name is Jonas." ); // store a string!
    circle.data( 'dataset', { ... } );          // store an object literal!
    circle.data( 'click_handler', function()
        {
            console.log("Store a handler function!" );
        } );
    

    At this point, the game becomes very easy. Whether you use Raphael’s built in hover handling…

    circle.hover( function()
        {
            console.log("Just moved over '" + this.data("name") + "'" );
        }, function()
        {
            console.log("Just moved out of '" + this.data("name") + "'" );
        } );
    

    …or a mouseover event powered, for instance, by jQuery…

    //  Don't forget to translate page coordinates relative to the paper!
    var element = paper.getElementByPoint( x, y );
    if ( element && element.data("name") == "c" )
    {
        // bah, humbug
    }
    

    …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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can you tell me your opinion of this, and possibly see if you can
Can you tell me your opinion of this, and possibly see if you can
As far as I can tell, this code is fine, and should display some
As far as I can tell I wouldn't think it would make any difference
i saw some online flash games can do this: when you switch your current
I was wondering if someone can tell me what would be the best way
Can you please tell me your way or give me a reference to best
Caution: This question is over nine years old! Your best option is to search
Is there any way to tell your localhost that it can do cross domain
Anyone can tell me which one is better (JAXB or Apache XMLBeans) taking in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.