mardi 9 mars 2021

Cannot set img width/height in SetDragImage()

I was trying to customize drag image. What I did was

dragStart(event) {
    event.dataTransfer.setData('type', event.target.getAttribute('data-type'));
    event.dataTransfer.setData('id', event.target.id);

    let img = document.createElement('img');
    img.setAttribute('src', event.target.src);
    img.style.width = '50px';
    img.style.height = '50px';
    event.dataTransfer.setDragImage(img, 0, 0);
  } 

I tried various ways but the drag image is still the same size as my src. Screenshot

Thanks.




Aucun commentaire:

Enregistrer un commentaire