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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:28:52+00:00 2026-05-31T18:28:52+00:00

This is a problem where firefox works just fine, while chrome has the problem.

  • 0

This is a problem where firefox works just fine, while chrome has the problem. Opera has additional problems I need to adress and IExplore I haven’t bothered testing yet (don’t care right now to be quite honest).

I have an experiment going, where I rotate a picture of a car seen from above using JqueryRotate (sets the rotation of an element) and the left right arrow keys. The car is set to the center using javascript/jquery(works – no problem). If the up arrow is used, the car moves up in the direction it points – here is where the problem occurs. Don’t mind the fact that you can’t turn and drive at the same time, this will be fixed, no prob. But the picture moves a bit after I have turned it and then move forward? Why?

the javascript:

    var angle = 0;
var degreeInRadians = 2*Math.PI/360;
var realX = 0; 
var realY = 0;

$(document).ready(function(){
    placeInCenter($("#carImage"));
});

$(document).keydown(function(e){
    //left
    if (e.keyCode == 37) { 
        rotateLeft($("#carImage"));
        return false;
    }
    //up
    if (e.keyCode == 38) { 
        moveForward($("#carImage"),1);
        return false;
    }   
    //right
    if (e.keyCode == 39) { 
        rotateRight($("#carImage"));
        return false;
    }
    //down
    if (e.keyCode == 40) { 
        //TODO move the car forward
        return false;
    }    
});



function placeInCenter(element) {
    // get viewport height and width and divide it by 2
    centerY = window.innerHeight/2;
    centerX = window.innerWidth/2;

    //set absoulte positioning on element
    $(element).css("position", "absolute");
    // place the element
    $(element).offset({ top: centerY, left: centerX });
    //update realX and realY
    realX = centerX;
    realY = centerY;
}

function rotateRight(element) {
    if(angle <360) {
        angle++;
    }
    else {
        angle=0;
    }
    element.rotate(angle);
}

function rotateLeft(element) {
    if(angle > 0) {
        angle--;
    }
    else {
        angle=359;
    }
    element.rotate(angle);
}

function moveForward(element, speed) {
    //move the element to polar cordinate (speed,angle)
    realX = realX + Math.cos(degreeInRadians * angle);
    realY = realY + Math.sin(degreeInRadians * angle);

    $(element).offset({ top: realY, left: realX });
}

the demo: http://www.perandersen.no/sandbox/fromAbove/

  • 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-31T18:28:53+00:00Added an answer on May 31, 2026 at 6:28 pm

    The problem is that WebKit seems to set offset from the bounding box of the rotated element, while Firefox offsets it from the original bounding box, and then applies the rotation.

    Place your finger at the corner of the car, rotate it, and then move it forward. The upper left corner of the car’s bounding box (its furthest left and top points after rotation) will line up with your finger.

    It seems to works fine in Firefox and WebKit if you use .css({ top: ... left: }) instead of .offset(), and set the following css style:

    #carImage {
        position: relative;
        margin-left: -100px;
        margin-top: -51px;    
    }
    

    Demo: http://jsfiddle.net/jtbowden/2aeyP/2/

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

Sidebar

Related Questions

I have a Firefox 3.6.2 problem (3.5.x works just fine). This is the code:
I have a Greasemonkey script that works just fine in Firefox and Opera. I
I'm encountering a problem with a SSL certificate. Everything works perfect in Opera, Firefox,
This problem only occurs using IE (only tested in IE 7, works fine in
How do you get around this Ajax cross site scripting problem on FireFox 3?
This page displays beautifully in firefox but i get all kinds of problems when
This problem has been solved thanks to your suggestions. See the bottom for details.
This problem has been kicking my butt for a few days now. I have
I just figured out that I have a problem in IE while working with
I have created a shader that works perfectly in Firefox, but in Chrome the

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.