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

202
Visualizações
Cannot perform Shift + Drag on a div element containing an embedded SVG image

I have a draggable div containing an en embedded SVG image like this:

<div draggable="true">
  <svg width="160" height="40" xmlns="http://www.w3.org/2000/svg">
    <g>
      <text x="26.5" y="15" style="font-size: 20px;">Drag me</text>
    </g>
   </svg>
</div>

I can drag the div, I can do Alt + Drag but when I perform a Shift + Drag nothing happens, apparently the drag start event is not invoked at all. How can I make Shift + Drag work?

Please note that the bug mentioned here: Draggable with shift key doesn't work in Chrome appears to be fixed in the latest version of Chrome while the problem I mention still occurs.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This is a known bug in Chromium, Firefox works fine

  • https://bugs.chromium.org/p/chromium/issues/detail?id=982219

    • You can not start a Shift-Drag operation if the Element has Nodes, other then text

    • If you start the drag with one click, you can add the shift key during the drag

    • If you click a "root" Textnode first, you can start dragging with the shift key down
      (click on the word 'tag' in the items below in the SO snippet)

If dragging SVGs is your objective, do read: https://www.petercollingridge.co.uk/tutorials/svg/interactive/dragging/

<script>
  function initDrag(tag, html = 'No HTML content') {
    document.body.appendChild(Object.assign(document.createElement(tag),{
      innerHTML : `tag:${tag} ` + html,
      ondrag : evt => LOG.innerHTML = `Shift ${evt.shiftKey?"On":"Off"} `
    })).setAttribute("draggable", "true");
  }

  let htmlContent = `<b style="color:red;font-size:20px">with HTML content</b>`;

  initDrag("h3");
  initDrag("h3", htmlContent);
  initDrag("div");
  initDrag("div", htmlContent);
</script>

<h2 id="LOG" style="background:lightgreen">[shift key state]</h2>

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