Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda