I'm trying to create a drag function using a combination of jQuery mousedown/move/up events, during which I'm trying to pass the starting (cursor) position of the mousedown event to the mousemove event handler but am getting the error
Argument of type mousemove is not assignable to the type 'PlainObject...'
Here's my code...
module controls.draganddrop {
export function init() {
$("#mainContent").on("mousedown", ".itemList > ul > li > p", mouseDown);
$("#mainContent").on("mouseup", ".itemList > ul > li > p", mouseUp);
}
function mouseDown(e) {
var startPosition: object = { x: e.pageX, y: e.pageY };
$(".itemList > ul > li > p").on("mousemove", mouseMove(event, startPosition));
}
function mouseMove(e, startPosition) {
console.log("pageX: " + e.pageX + ", pageY: " + e.pageY);
}
function mouseUp(e) {
$(".itemList > ul > li > p").off("mousemove", mouseMove);
}
}
The error is on "mousemove" within the mouseDown function. Clearly I've misunderstood something in the jQuery documentation and/or solutions in similar problems, what am I doing wrong?