To address this issue, I recommend implementing additional state within your DOM node to indicate whether the object has been moved or not. By checking this state, you can prevent the click event from being triggered unnecessarily.
Here is an example of how to add this state:
lang.mixin(domNode, {
moved: false
});
When the Move
event occurs, you can update the flag accordingly like so:
moveable.on("Move", function(mv, pos, evt) {
if (evt.target.moved === false) {
console.log("Drag detected");
}
evt.target.moved = true;
});
In the click event handler, ensure that you check the flag's value and reset it back to false
after processing, as demonstrated below:
on(domNode, "click", function(evt) {
if (evt.target.moved === false) {
// Implement your logic here
}
});
While this solution may not be the most elegant, it proves to be effective. Alternatively, consider extending the functionality of Moveable
to better suit your requirements for a more tailored solution.
I have validated this approach through a JSFiddle demonstration available here.