Comments (3)
It’s possible that Firefox is slightly slower to trigger the click event following a drag gesture, so our zero-millisecond timeout in nodrag.js isn’t working to suppress click following drag.
setTimeout(function() { selection.on("click.drag", null); }, 0);
Could you try increasing the timeout and seeing if that fixes the problem?
from d3-drag.
@mbostock I have tried to replace the timeout like you said but it doesn't seems to make any difference. The click is still triggered twice in Firefox.
from d3-drag.
I’m not able to reproduce this issue, and this issue does not include a live example that demonstrates the problem, so I am afraid I cannot further investigate and am closing this issue. When reporting an issue, please include a link to a live example, preferably on bl.ocks.org or RunKit, or as a pull request in the appropriate repository with new unit tests, that demonstrates that the described behavior is not the expected behavior. Use only the minimum amount of code necessary to reproduce the unexpected behavior.
I tried to reproduce this issue by adding a click handler to this example, and it worked as expected in both Chrome and Firefox (on macOS):
https://bl.ocks.org/mbostock/2990a882e007f8384b04827617752738
I suspect that there may be an issue with your use of what appears to be selection.raise in the code snippet. Since this method may re-insert the selected elements into the DOM, it may prevent a subsequent click event, since browsers only trigger a click event if the mousedown and mouseup occur on the same element, and re-inserting an element may cause the browser to consider the re-inserted element a different element (even though it is technically the same). In some cases I have found it necessary to defer raising the element until mousemove, rather than raising on mousedown. However, it might be desirable to raise on mousedown, in which case you will have to trigger the click event manually. Whichever approach you choose, I would not consider this behavior to be an issue with d3-drag, since it is caused by raising the element.
While not directly related to this issue, I’ll also mention that I just committed a fix to #28.
Thank you!
from d3-drag.
Related Issues (20)
- Possible typo in README HOT 2
- What are the perposes of functions yesdrag and nodrag?
- Drag event on Chrome 72 HOT 3
- d3 mouseup event not firing HOT 1
- Drag Event Issue on Windows Chrome 74, related to solution for #47 HOT 1
- The default filter should return false if event.ctrlKey. HOT 5
- drag start event is don't send when Ctrl-key is press HOT 1
- drag.on("init") ? HOT 7
- Click event not firing if drag enables with simulation HOT 1
- Non-cancelable event HOT 3
- remove drag.container? HOT 1
- Use native events (*element*.dispatchEvent) instead of d3-dispatch? HOT 1
- remove dragEvent.on?
- d3.event is not available in version 6.1.1 HOT 1
- DragEvent missing event.currentTarget for arrow function node selection HOT 1
- Make event listeners non-passive. HOT 2
- d3.drag() causes error in testing mousedown event via jsdom HOT 4
- d3.pointer() could use event.touches[0] HOT 2
- Add event.currentTarget
- Support d3.drag in testing environments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-drag.