0

So I'm trying to drag and element from a div into an other div. The problem is that I can't get the right position to drop the new element in it's new parent. While dragging I can get the position but it come in negative.

I have tried to append the new element in the new div the instant it enters the area using dragenter event, but it didn't solve the problem. Are there any idea's? Here is a screenshot from the console.

1: chrome console screenshot

Kaki Master Of Time
  • 1,428
  • 1
  • 21
  • 39
  • Don't really understand the "the wite position to drop"... Any code you can show us? – Jorge Fuentes González Jul 30 '16 at 12:26
  • `function drag_start(event) { var style = window.getComputedStyle(event.target, null); event.dataTransfer.setData("text/plain", (parseInt(style.getPropertyValue("left"),10) - event.clientX) + ',' + (parseInt(style.getPropertyValue("top"),10) - event.clientY)); } function drag_over(event) { event.preventDefault(); mod=document.getElementsByName('module'); var offset = event.dataTransfer.getData("text/plain").split(','); CX= (event.clientX + parseInt(offset[0],10)); CY= (event.clientY + parseInt(offset[1],10)); ` this is the code that gets the positions – Kaki Master Of Time Jul 30 '16 at 12:41
  • Instead of getting the computed CSS left, get the offset position: http://stackoverflow.com/questions/288699/get-the-position-of-a-div-span-tag – Jorge Fuentes González Jul 30 '16 at 15:42

0 Answers0