Skip to content

Commit

Permalink
Correct way to click events
Browse files Browse the repository at this point in the history
  • Loading branch information
igrep committed Apr 12, 2022
1 parent 61c016d commit e4ec867
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions eval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,10 @@ export function evaluate(
break;
}
}

stage.addEventListener("click", handleClick);
stage.addEventListener("mousemove", handleMouseMove);
stage.addEventListener("mousedown", handleMouseDownMove);
stage.addEventListener("mousemove", handleMouseDownMove);
stage.addEventListener("mouseup", handleMouseUp);
function handleClick(e: MouseEvent) {
const { x, y } = stage.getBoundingClientRect();
Expand All @@ -306,7 +308,7 @@ export function evaluate(
plugState[vertex.plugs.y] = e.clientY - y;
}
}
function handleMouseMove(e: MouseEvent) {
function handleMouseDownMove(e: MouseEvent) {
if (e.buttons === 0) {
return;
}
Expand All @@ -333,7 +335,7 @@ export function evaluate(
return () => {
runState.shouldStop = true;
stage.removeEventListener("click", handleClick);
stage.removeEventListener("mousemove", handleMouseMove);
stage.removeEventListener("mousemove", handleMouseDownMove);
stage.removeEventListener("mouseup", handleMouseUp);
stage.innerHTML = "";
};
Expand Down

0 comments on commit e4ec867

Please sign in to comment.