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

149
Visualizações
PIXI Interaction - Retargeting canvas doesn't work as expected

I'm currently trying to make PIXI interaction work with DOM elements. My goal is as follow : when the user hovers a block, I want to show a dropdown (a red <div> for now), and when it leaves the div, I want the interaction to go back to the canvas.
To do so, I'm using the PIXI.InteractionManager and it's method setTargetElement. At first, the target is the canvas, and when the red box is shown, it becomes the target element. So far, everything works as expected. But when the cursor leaves the box, I'm using setTargetElement and give it the canvas, and then there is a strange issue, as shown in the gif.
enter image description here In the gif, you can see that the circle follows the cursor with no issue, then disappears on the red box (which is not a problem), and then, when the cursor leaves the box, the circle has a kind of scale effect (it's not a fixed offset because at 0,0, the cursor and the circle are superposed).

In a simplified version, this is what I do :

// Creates the circle that follows the pointer
initialization() {
  this.app.stage.on('pointermove', (e) => {
        circle.position.copyFrom(e.data.global)
  })
}

// When the blue box is hovered
onHoverBlock() {
  // Get the red box from the DOM
  const redBox = document.getElementById('red-box')
  // Tell the interaction manager to target the box
  this.app.renderer.plugins.interaction.setTargetElement(redBox)
}

// Called on the `mouseleave` of the red box
onMouseLeaveRedBox() {
  // Assign the canvas back to the interaction manager
  this.app.renderer.plugins.interaction.setTargetElement(
        this.canvasReference
  )

  // From this point, the circle doesn't follow the pointer anymore 😟
}

Do you know what is happening, and how to solve this issue ?

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

0

Okay, the answer is pretty simple after all; setTargetElement also takes a resolution parameter that is set to 1 by default... while my app runs at a resolution of 2. 🤦‍♂️
I just need to pass my HTML element and my resolution (usually app.renderer.resolution) and it's working!

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