It is because of this line
var oldMousePos = checkMousePos();
function checkMousePos(e) {
return [e.pageX,e.pageY];
}
It is reading the position based on the Event
object . But it is a simple function call.
Pass the event object to the method
function checkDragDropEdit(e) {
... // Pass the event object
var oldMousePos = checkMousePos(e);