Coder Social home page Coder Social logo

Comments (3)

mbostock avatar mbostock commented on April 28, 2024

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.

amillette avatar amillette commented on April 28, 2024

@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.

mbostock avatar mbostock commented on April 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.