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

  • Home
  • SEARCH
  • 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 721181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:50:38+00:00 2026-05-14T05:50:38+00:00

I’m having a Firefox-specific issue with a script I wrote to create 3d layouts.

  • 0

I’m having a Firefox-specific issue with a script I wrote to create 3d layouts.

The correct behavior is that the script pulls the background-color from an element and then uses that color to draw on the canvas. When a user mouses over a link and the background-color changes to the :hover rule, the color being drawn changes on the canvas changes as well. When the user mouses out, the color should revert back to non-hover color.

This works as expected in Webkit browsers and Opera, but it seems like Firefox doesn’t update the background-color in CSS immediately after a mouseout event occurs, so the current background-color doesn’t get drawn if a mouseout occurs and it isn’t followed up by another event that calls the draw() routine. It works just fine in Opera, Chrome, and Safari. How can I get Firefox to cooperate?

I’m including the code that I believe is most relevant to my problem. Any advice on how I fix this problem and get a consistent effect would be very helpful.

function drawFace(coord, mid, popColor,gs,x1,x2,side) {
    /*Gradients in our case run either up/down or left right.
    We have two algorithms depending on whether or not it's a sideways facing 
    piece. Rather than parse the "rgb(r,g,b)" string(popColor) retrieved from 
    elsewhere, it is simply offset with the gs variable to give the illusion that it 
    starts at a darker color.*/

    var canvas = document.getElementById('depth');
//This is for excanvas.js
    var G_vmlCanvasManager;
    if (G_vmlCanvasManager != undefined) { // ie IE
        G_vmlCanvasManager.initElement(canvas);
    }
    //Init canvas
    if (canvas.getContext) {
        var ctx = canvas.getContext('2d'); 
        if (side) var lineargradient=ctx.createLinearGradient(coord[x1][0]+gs,mid[1],mid[0],mid[1]);
        else var lineargradient=ctx.createLinearGradient(coord[0][0],coord[2][1]+gs,coord[0][0],mid[1]);
        lineargradient.addColorStop(0,popColor);
        lineargradient.addColorStop(1,'black');
        ctx.fillStyle=lineargradient;
        ctx.beginPath();
        //Draw from one corner to the midpoint, then to the other corner, 
        //and apply a stroke and a fill.
        ctx.moveTo(coord[x1][0],coord[x1][1]);
        ctx.lineTo(mid[0],mid[1]);
        ctx.lineTo(coord[x2][0],coord[x2][1]);
        ctx.stroke();
        ctx.fill();
    }
}

function draw(e) {
    var arr = new Array()
    var i = 0;
    var mid = new Array(2);
    $(".pop").each(function() {
        mid[0]=Math.round($(document).width()/2);
        mid[1]=Math.round($(document).height()/2);
        arr[arr.length++]=new getElemProperties(this,mid);
        i++;
    });
    arr.sort(sortByDistance);
    clearCanvas();
    for (a=0;a<i;a++) {
        /*In the following conditional statements, we're testing to 
        see which direction faces should be drawn,
        based on a 1-point perspective drawn from the midpoint. In the first 
        statement, we're testing to see
        if the lower-left hand corner coord[3] is higher on the screen than the 
        midpoint. If so, we set it's gradient
        starting position to start at a point in space 60pixels higher(-60) than 
        the actual side, and we also declare which corners make up our face, 
        in this case the lower two corners, coord[3], and coord[2].*/
        if (arr[a].bottomFace) drawFace(arr[a].coord,mid,arr[a].popColor,-60,3,2);
        if (arr[a].topFace) drawFace(arr[a].coord,mid,arr[a].popColor,60,0,1);
        if (arr[a].leftFace) drawFace(arr[a].coord,mid,arr[a].popColor,60,0,3,true);
        if (arr[a].rightFace) drawFace(arr[a].coord,mid,arr[a].popColor,-60,1,2,true);
    }
}

$("a.pop").bind("mouseenter mouseleave focusin focusout",draw);

If you need to see the effect in action, or if you want the full Javascript code, you can check it out here:
http://www.robnixondesigns.com/strangematter/

  • 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-14T05:50:39+00:00Added an answer on May 14, 2026 at 5:50 am

    You could delay your javascript method by a few milliseconds by using a callback.

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

Sidebar

Ask A Question

Stats

  • Questions 360k
  • Answers 360k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Simply: from nose.tools import assert_equal from mock import Mock class… May 14, 2026 at 2:36 pm
  • Editorial Team
    Editorial Team added an answer Don't reinvent the wheel if perfectly round wheels are already… May 14, 2026 at 2:36 pm
  • Editorial Team
    Editorial Team added an answer I dont think this option is exposed va the api.… May 14, 2026 at 2:36 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.