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

156
Visualizações
Interactjs : Random error: TypeError: Cannot read properties of undefined (reading 'left')

I am using interact.js in my Ionic + Vue project. I have screen where there is on circle on screen when it is dragged it is cloned into parent element. Code is shown below. This works most of the time in real browser (not 100%). But on my mobile I always get this weird error and I do not understand why. I tried to figure out why and where it is comming from. I tracked bug down to this line of code :

interaction.start({ name: "drag" }, event.interactable, element);
   .on('move', dragOrClone); // this function that cases error is called on this line of global interact instance

    const dragOrClone = (event) => {
      const { currentTarget, interaction } = event;
      let element = currentTarget;

      if(
          interaction.pointerIsDown &&
          !interaction.interacting() &&
          currentTarget.style.transform === ""
      ) {
        element = currentTarget.cloneNode(true);

        element.style.position = "absolute";
        element.style.left = 0;
        element.style.top = 0;
        element.style.width = '24px';
        element.style.height = '24px';
        element.style.transform = 'translate(0px, 0px)';
        element.classList.remove('bg-yellow-800');
        element.classList.add('bg-yellow-600');

        // Adding object inside parent container element
        dropzone && dropzone.appendChild(element);

        position.x = 0;
        position.y = 0;

        // If we are moving an already existing item, we need to make sure the position object has
        // the correct values before we start dragging it
      }else if(
          interaction.pointerIsDown &&
          !interaction.interacting()
      ) {
        updatePositionFromTransform(currentTarget);
      }

      // Start the drag event
      interaction.start({ name: "drag" }, event.interactable, element);
    };

Edit : Also this circle that is used for cloning others does not have transform value so if statement which cloned object can be true. But when I but transform on it I do not see this error but this then breaks my intention of cloning object.

about 4 years ago · Juan Pablo Isaza
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