Mercurial Hosting > dad
comparison src/examples/drop.html @ 5:1293cb0d30da
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 23 Apr 2023 17:14:52 -0600 |
parents | 0130ae25ef94 |
children | 332d3e280f7e |
comparison
equal
deleted
inserted
replaced
4:0130ae25ef94 | 5:1293cb0d30da |
---|---|
23 dad.whatToDrag = function(draggable) { | 23 dad.whatToDrag = function(draggable) { |
24 return draggable.parentNode; | 24 return draggable.parentNode; |
25 }; | 25 }; |
26 | 26 |
27 dad.onDrop = function(event) { | 27 dad.onDrop = function(event) { |
28 let draggable = event.draggable; | 28 let original = event.original; |
29 let style = draggable.style; | 29 let style = original.style; |
30 let left = style.left ? parseInt(style.left) : 0; | 30 let left = style.left ? parseInt(style.left) : 0; |
31 let top = style.top ? parseInt(style.top) : 0; | 31 let top = style.top ? parseInt(style.top) : 0; |
32 let rectDragged = event.dragged.getBoundingClientRect(); | 32 let rectDragged = event.dragging.getBoundingClientRect(); |
33 let rectDraggable = draggable.getBoundingClientRect(); | 33 let rectDraggable = original.getBoundingClientRect(); |
34 left += rectDragged.x - rectDraggable.x; | 34 left += rectDragged.x - rectDraggable.x; |
35 top += rectDragged.y - rectDraggable.y; | 35 top += rectDragged.y - rectDraggable.y; |
36 style.left = left + 'px'; | 36 style.left = left + 'px'; |
37 style.top = top + 'px'; | 37 style.top = top + 'px'; |
38 }; | 38 }; |