I have a page where im trying to perform a drag/drop function on a rect
Problem is, when I’m done dragging and a javascript function is run to save a few variables and submit a form
function endDrag(evt) {
selectedElement = false;
var coord = getMousePosition(evt);
//console.log("x: "+ Math.floor(coord.x - offset.x));
//console.log("y: "+ Math.floor(coord.y - offset.y));
document.getElementById("x_coord").value = Math.floor(coord.x - offset.x);
document.getElementById("y_coord").value = Math.floor(coord.y - offset.y);
document.getElementById("height").value = document.getElementById('moving_device').getAttribute("height");
document.getElementById("to_rack_slots").value = 45;
document.getElementById("New_Position").submit();
}
The resulting page (after I drag the element onto the other rack)
but if I try again
the element was dragged to just about the same position, so why are the coordinates so different?
I dont knoww why the y_coord is negative.