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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:23:09+00:00 2026-06-12T16:23:09+00:00

I know questions regarding svg mouse coordinates have been asked here before, but I’m

  • 0

I know questions regarding svg mouse coordinates have been asked here before, but I’m quite puzzled by the current behavior I’m experiencing and none of the threads quite seems to address it.

The method I use for capturing coordinates:

var pt = svg.createSVGPoint();  // Created once for document

function alert_coords(evt) {
    pt.x = evt.clientX;
    pt.y = evt.clientY;

    // The cursor point, translated into svg coordinates
    var cursorpt =  pt.matrixTransform(svg.getScreenCTM().inverse());
    console.log("(" + cursorpt.x + ", " + cursorpt.y + ")");
}

The problem is with converting mouse click coordinates into the svg coordinates in the user space. I’m using the coordinates to drag a rectangle across the screen, and as the cursor gets further to the right in the svg space the coordinates become more and more skewed. To test this in a simple manner, I put three rectangles in global svg space at (100, 500), (500, 500), (1000, 500), and (1000, 200). Using a simple logging function the coordinates I receive(plus or minus 5 for mouse imprecision) are (98, 473), (487, 470), (969, 471), (969, 190). As you can see the further along the x or y axis the mouse goes, the more inaccurate it becomes. I tried to replicate this in a fiddle using the same method for capturing mouse coordinates, but I can’t replicate it there… One more thing to note that may be significant is the fact that when I log the svg document, the width and height are set to values slightly less than the viewbox values, ie. 1380 width and 676 height given the viewbox value of “0 0 1400 700”. Anyway, here’s the fiddle, all the svg properties are the same as they are in my program.

http://jsfiddle.net/ASLma/11/

  • 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-12T16:23:10+00:00Added an answer on June 12, 2026 at 4:23 pm

    It seems the problem was opening the svg directly in the browser. Instead, I embedded it in an html page via an embed tag, and it works great. I’m not sure why that would matter in terms of my mouse coordinate accuracy, but a solution is a solution.

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

Sidebar

Related Questions

I know similar questions (regarding cherry-picking) have been asked before, but I haven't really
I know similiar questions have been asked before, but please bear with me as
I know similar questions have been asked before, but I've tried many times and
I know similar questions have been asked, but I'm not sure about the answers
First of all I know similar questions has been asked here, I've checked but
The questions regarding Bootstrapper & Chaining might have been asked before. I am trying
i have questions regarding the shake detection that posted here before, here is a
So I know there have been multiple questions regarding Money and converting to and
I know there have been several questions regarding the mousewheel and scrolling; I'm not
I know there has been several questions regarding this very question and I have

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.