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

242
Views
No se puede colocar el elemento más cercano después de arrastrar con elementFromPoint

document.elementFromPoint define el elemento antes o después del cual se debe insertar el elemento arrastrado. Cuando uso este método, devuelve el elemento que se está arrastrando, no el que se va a definir. ¿Por qué no sucede y cómo soluciono el error?

 evt.preventDefault(); if (!draggedEl) { return; } draggedEl.style.left = `${evt.pageX - draggedEl.offsetWidth / 2}px`; draggedEl.style.top = `${evt.pageY - draggedEl.offsetHeight / 2}px`; **const closest = document.elementFromPoint(evt.clientX, evt.clientY);** const { top } = closest.getBoundingClientRect(); if (evt.pageY > window.scrollY + top + closest.offsetHeight / 2) { // closest.style.paddingBottom = `${draggedElWidth}px`; } else { // closest.style.paddingTop = `${draggedElWidth}px`; } });

Código completo: https://github.com/tati-simonenko/ahj6/blob/master/src/js/taskWidget.js

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