Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
fabric.js updating line coordinates

I have set up an arrow with fabric.js using a line and a triangle rotated 90 degrees. I have set these up in a Group so that they will move together.

When I double click on the arrow, I have a circle being placed at each end of the arrow's line. When I move these circles I want the corresponding end of the arrow to be moved to wherever my pointer moves while the other end stays in place.

Currently, when I move one of the circles, the line of the arrow is shifted away from it's current position and then as I move the circle the line updates it's position from the place it gets shifted to. I'm guessing this shift is happening because I'm missing something with the group.

Here is my function that is handling when a circle is being moved:

handleDrag: function(obj) {
    const pointer = obj.pointer
    const target = obj.transform.target
    const line = target.line
    line.set({
        x1: line.x1,
        y1: line.y1,
        x2: pointer.x,
        y2: pointer.y,
    })
    line.setCoords()
},

The target would be the circle that is being moved and when I add the circle I give it the line that it is supposed to move so that I can use target.line to get the line and update its coordinates.

Here is a codepen so you can see what is happening now:
https://codepen.io/jrabes/pen/ExoJZgJ

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda