Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
SVG getScreenCTM does not account for CSS transforms in Firefox

I'm trying to calculate an svg's viewBox coordinates of a click event using

const { x, y } = new DOMPoint(event.clientX, event.clientY)
   .matrixTransform(svg.getScreenCTM().inverse());

My svg lives inside a container that is CSS-transformed (translate). In Chrome everything is working fine, in Firefox the correct viewBox coords are calculated only if I remove the CSS-transform.

What can be done? Any help would be much appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The different behaviour you are seeing in Chrome is probably due to it being a little more advanced in its support of SVG 2 specification changes.

In the definition for getScreenCTM in the SVG 2 specification it says that among the transforms to be considered is included:

  • any transforms from the SVG viewport's coordinate space to the document's viewport, i.e. taking into account the positions of all of the CSS boxes from the outermost svg element's box to the initial containing block when the SVG document fragment is inline in an HTML document

This language is not in the SVG 1.1 specification.

This (the missing SVG2 behaviour) is a known bug in Firefox. You can view the bug report here.

As for a workaround, I don't think there is an easy answer. AFAIK there is no equivalent of getScreenCTM() for HTML elements. You could read the container element's transform property, parse it, then multiply it with the matrix you get from getScreenCTM(). But you probably also need to take account of the page offsets of the container and all its ancestors.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!