question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

canvas-click event shouldn't fire as you drag

See original GitHub issue

I just wrote a little test for canvas-click:

viewer.addHandler('canvas-click', function(target, info) {
  console.log(info.position.x, info.position.y);
});

… and noticed that it fires for every mouse move while I drag. Having a canvas-drag event would probably be a good idea, but conflating the two events doesn’t seem like a good idea. Let’s get that sorted out.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
msalsberycommented, Sep 30, 2013

In the current event implementation, a click event is always raised when the mouse button is released. To differentiate between a click and a drag in your click handler, examine the “quick” parameter passed to your handler - it will be false for a drag, true for a click.

0reactions
raducristiancommented, Oct 4, 2013

Works like a charm. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React synthetic event: onDrag doesn't fire after onClick or ...
It fires only in drag & drop context. To implement dragging behavior in canvas I used classic. mousedown, mouseup and mousemove events.
Read more >
How to differentiate mouse “click” and “drag” event using ...
In a “click” event, there is no “mouse move” event. However, the “mouse down” and “mouse up” event remains the same for both...
Read more >
HTML5 Canvas Fire Event with Konva
To fire events with Konva, we can use the fire() method. This enables us to programmatically fire events like click , mouseover ,...
Read more >
ondrag Event - W3Schools
Links and images are draggable by default, and do not need the draggable attribute. Many events occur in the different stages of a...
Read more >
Drag'n'Drop with mouse events - The Modern JavaScript Tutorial
Not bad, but there's a side effect. To initiate the drag'n'drop, we can mousedown anywhere on the ball. But if “take” it from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found