Note that there are some explanatory texts on larger screens.

plurals
  1. POCoordinate transformation in SVG inside Firefox with scrollbars
    primarykey
    data
    text
    <p>I am trying to calculate the correct mouse coordinates, in user coordinate space, in an SVG document from within Javascript code when scrollbars come into existence when that SVG file is viewed from within FireFox. But it is not quite correct. This is needed to get SVG-based tooltips drawn correctly even when the SVG is scrolled horizontally or vertically.</p> <p>I desire to have the coordinate transformations be correct across IE and Firefox browsers. Also, I want to do this with a single-source Javascript+SVG solution that hopefully does not require browser-specific conditional code. I am currently using FireFox 3.5.10, but I would consider upgrading to a more recent version of FireFox, and I have not tested IE yet.</p> <p>The problem I ran into is the coordinate offsets for the scrollbars: The mouse coordinate transformation is not sufficient when scrollbars come into existence over the SVG element inside Firefox. As a debugging aid to figure out the coordinate transformations, I am working with a simple SVG file that contains Javascript handlers, all in one file, that simply draws crosshairs at the mouse cursor as SVG line objects. Find it posted at <a href="http://gist.github.com/517462" rel="nofollow noreferrer">svg_cross_hairs.svg</a>. If you load that file into FireFox and shorten the FireFox window down until scrollbars appear, and then scroll either the vertical or horizontal scrollbars, you will find that the crosshairs drawn by the Javascript are offset by the amount of either horizontal or vertical scrolling amount, which is not correct in order to draw a tooltip object on or near where the mouse cursor actually is.</p> <p>I do see the <a href="https://stackoverflow.com/questions/1045456/firefox-get-mouse-coordinates-of-top-left-corner-of-viewport">Firefox: Get mouse coordinates of top-left corner of viewport</a> question that talks about the <a href="https://developer.mozilla.org/en/DOM/element.scrollTop" rel="nofollow noreferrer">scrollTop</a> property. </p> <p><a href="http://osdir.com/ml/web.svg/2003-08/msg00056.html" rel="nofollow noreferrer">msg#00056</a> clarifies that there is confusion of the meanings of <code>element.{pageX,pageY,clientX,clientY}</code> attributes and the <code>element.getscreenCTM</code> method.</p> <p>Is there a cleaner way to arrive at the correct mouse coordinate, in the in user coordinate system?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload