lundi 9 septembre 2019

If statement not working with classList.containes on touchstart

I have the code working and it will do what I want when I drag and drop. The only bug I can't seem to fix is when I click on an item the code breaks and I get an error saying Uncaught TypeError: Cannot read property 'classList' of undefined

  if (targetElement && 
    targetElement.classList.contains('imageContainer')) 
  {
    logic.pop(event.target.id);
  }
     element.style.width = '100%';
     element.style.left = '0px';
    element.style.height = 'auto';
    element.style.fontSize = '14px';
    if (element == "D_drag_1") {
       logic.pop();
      parent = document.querySelector('.contain_item');
      node.appendChild(element);
      parent.appendChild(node);
      element.style.width = '200px';
      element.classList.remove('alert');
      //element.classList.remove('active');
      element.classList.remove('alert-success');
      element.classList.remove("active");
      element.style.transform = "none";

   }

Aucun commentaire:

Enregistrer un commentaire