Basically I just want to get the position of a dragged element. I have read the previous questions like this one: How to get the position of a draggable object. But that is based on jQuery. Is there a way to achieve this with pure javascript?
I have tried something like below but doesn't work:
itemDrag() {
let card = document.querySelector("div.draggable");
let rect = card.getBoundingClientRect();
console.log(rect.top, rect.right, rect.bottom, rect.left);
}
I triggered this with ondrag event. It turns out that although the event is fired multiple times, the rect remains in the original position. Is there a way to handle that?