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

110
Vistas
drawing line selection issues

Hope you are all having a wonderful day..

so here's a thing i made a and online app with fabricjs and pdfjs " almost done", but i'm having some issues while drawing lines.. i'm using the latest version of FabricJS (5.2.1)

when i draw a line it will usefully draw with no issues, but when i try to select the draw line button an move the cursor around the canvas the previous drawing line stars following the cursor!! can anyone help me with this issue?

Also below there's further info about the app link, Line Drawing code, error and what i wanted to be

My issue: https://gfycat.com/harshspotlesscollie

This is what I'm trying to do: http://jsfiddle.net/vmachan/L10ren1q/

Draw Line Code (Found in viewer.js file: line 110):

$(".tool-button").on("click", function () {
      $(".tool-button").removeClass("active");
      $(this).addClass("active");
      const addLine = () => {
        if ($("#addLine").hasClass("active")) {
          mode="draw";
          isDown = true;
          canvas.on("mouse:down", function (o) {
            var pointer = canvas.getPointer(o.e);
            var points = [ pointer.x, pointer.y, pointer.x, pointer.y ];
            line = new fabric.Line(points, {
              strokeWidth: 5,
              fill: 'black',
              stroke: 'black',
              originX: 'center',
              originY: 'center',
              ObjectId: "id" + Math.random().toString(16).slice(2),
            });
            canvas.add(line);
            canvas.renderAll();
          });
          canvas.on('mouse:move', function(o){
            if (!isDown) return;
            if(mode=="draw"){
              var pointer = canvas.getPointer(o.e);
              line.set({ x2: pointer.x, y2: pointer.y });
              canvas.renderAll(); 
            }
          });
          
          canvas.on('mouse:up', function(){
            $(".tool-button").removeClass("active");
            isDown = false;
            canvas.selection=false;
          });
      };
      addLine();
    });
about 4 years ago · Juan Pablo Isaza
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