Transforming page coordinates into svg coordinates in viewbox doesn't report correct coordinates




6 years ago
6 years ago


(Reporter: stoffeastrom, Unassigned)


16 Branch
Windows 7

Firefox Tracking Flags

(Not tracked)




6 years ago
Sample is found here:

Click on the yellow rectangle. Notice the x, y in console. Press right arrow to pan the viewbox. Click the red rectangle. Notice that the x, y reported are the same as before which is wrong

Comment 1

6 years ago
My guess is that getScreenCTM.inverse() doesn't consider the viewbox

Comment 2

6 years ago
I can reproduce it in Nighty 19.0a1 (2012-10-17).

Actually the title of the bugg is wrong, the example is about transforming FROM SVG coordinates TO page coordinates.
viewBox applies to children of svg elements, not the parent svg element itself.
Last Resolved: 6 years ago
Resolution: --- → INVALID
Component: General → SVG
Product: Firefox → Core

Comment 4

6 years ago
So if yo don't have any children yet and want to add a child where the user clicks you can't do that? You first need to add the child and then get the correct x, y and then update the child's position?

Seems a bit odd to me. I agree that the viewBox applies to children but you still need to be able to use the svg element to get the correct coordinate since the svg establishes a new viewport.

If you wanted move the <svg> element itself that would be rather harder to do if we applied the viewBox transform to it when you queried where it was.
If you want to add an element where the user clicks, you can add it, get the TM from it, then use the TM to set its position. You were going to add it anyway. :)
You need to log in before you can comment on or make changes to this bug.