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 6822029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:36:53+00:00 2026-05-26T21:36:53+00:00

When I put a hover event on a raphael set, the efect is apply

  • 0

When I put a hover event on a raphael set, the efect is apply on every diffrent path. So, when I pass over the path, it changes the fill of that single path, not the fill of the whole set at the same time.

For example, in this map, when you pass through canada with the mouse, the mainland changes its color, but all the ice islands stays on the same color.

This is my code.

drawSets: function(){
    for (country in this.setsArr){
        var setset= R.set();
        var zone = this.setsArr[country];
        for (group in zone){
            var path = R.path(this.setsArr[country][group].path);

            setset.push(
                path
            );
        }

        var attri = this.options.attributes;
        setset.attr(attri);
        var x = this.setsArr[country].translate.x;
        var y = this.setsArr[country].translate.y;
        setset.translate(x,y);

        setset.hover(function(){
            this.animate({
                fill: '#000'
            }, 300);
        }, function(){
        this.animate({
            fill: attributes.fill
        }, 300);
    });

    }   
},

I’m using the Raphaels animate method.

Any ideas on how can I solve this problem?

And here is another question containing this one.

Can someone clarify Raphael's documentation? (or know a place in which someone already has done it)

  • 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-05-26T21:36:53+00:00Added an answer on May 26, 2026 at 9:36 pm

    This is the age old problem where the event you’re using to highlight isn’t referring to the object you think it is. Specifically the this reference.

    It’s midnight, I’m tired and I’ve messed with your code. Here’s what I did

    Create an object to wrap your set of paths, and setup the mouseover event to refer to the objects set. The magic here is that by using a reference to an object variable, the event will be locked to it and everything works.

    So. Heres the object. I put it at the top of mapclasses.js

    function setObj(country,myset)
    {
        var that = this;
        that.country = country;
        that.myset = R.set();
    
        that.setupMouseover = function()
        {
            that.myset.mouseover(function(event){
                myvar = that;   
                // in the mouseover, we're referring to a object member that.myset
                // the value is locked into the anonymous object
                that.myset.attr({"fill":"#ffaa00"});
            });
        }
    
        that.addPath = function(newpath)
        {
           that.myset.push(newpath); 
        }
    
        return that;
    }
    

    Then in the function drawSets (line 80)

    drawSets: function(){
        for (country in this.setsArr){
            var setset= R.set();
                        var holderObj = null;
                        //
                        // Create an object to hold all my paths
                        //
                        if (country == 'canada')
                        {
                           holderObj = setObj (country, setset);
                        }
            var zone = this.setsArr[country];
            for (group in zone){
                var path = R.path(this.setsArr[country][group].path);
    
                setset.push(path);
                                if (country == 'canada')
                                {
                                   // add the path to the holder obj
                                   holderObj.addPath(path);
                                }
            }
    
                        if (country == 'canada')
                        {
                           // once all paths for the object are loaded, create a mouseover
                           // event
                           holderObj.setupMouseover();
                        }
    
            var attri = this.options.attributes;
            setset.attr(attri);
            var x = this.setsArr[country].translate.x;
            var y = this.setsArr[country].translate.y;
            setset.translate(x,y);
    
    
    
        }   
    }
    

    Note: I’ve done this for Canada only. Also, I’ve only applied the mouseover. It should be trivial for you to apply the associated mouseout. Also you’ll need an object for each country, which you’ll probably want to store.

    Sorry this isn’t clearer. As I said, it’s late. If you want, I can send you the modified js file, or stick it onto dropbox, but that probably goes against the spirit of StackOverflow.

    If you have any problems with this, ask away and I’ll try to help.

    Best of luck.

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

Sidebar

Related Questions

I put together a simple drop-down navigation that expands when you hover over a
I have this site, please note that in a:hover put the source as bold.
I had a div with links that underlined once you hover over them. I
I'm trying to attach a hover event handler to a path within an embedded
I need to put a custom hover menu from http://www.addthis.com/help/toolbox , but Rails uses
Put differently: Is there a good reason to choose a loosely-typed collection over a
Put it another way: what code have you written that cannot fail. I'm interested
We put all of our unit tests in their own projects. We find that
To put it simple, there's a simple java swing app that consists of JFrame
So I have this dropdown menu, when you hover over a link a dropdown

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.