Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
Cambiar la imagen de arrastre dentro de un evento DragEnter

Estoy tratando de definir la imagen que aparece cuando arrastro un elemento dentro de mi página. Vi cómo hacerlo con DataTransfer.setDragImage() en ese enlace pero conmigo no funciona. Hay dos diferencias entre mi código y el ejemplo:

  • Estoy tratando de hacer este cambio a través del evento DragEnter mientras el enlace se realiza en DragStart ;
  • La imagen que se arrastrará estará en el explorador de archivos del usuario, no en el documento HTML.

Ya hice una prueba y la imagen se está generando correctamente. Este es el código responsable de esta funcionalidad:

 function handleDragEnter(event) { const img = new Image; const reader = new FileReader; reader.readAsDataURL((new Blob(icon(faPhotoFilmMusic).html, { type: 'image/svg+xml' }))); reader.addEventListener('load', () => { img.src = reader.result; event.dataTransfer.setDragImage(img, 10, 10); }); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que el problema está en la falta de paréntesis:

 function handleDragEnter(event) { const img = new Image(); // <=== change this const reader = new FileReader(); // <=== change this reader.readAsDataURL((new Blob(icon(faPhotoFilmMusic).html, { type: 'image/svg+xml' }))); reader.addEventListener('load', () => { img.src = reader.result; event.dataTransfer.setDragImage(img, 10, 10); }); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!