From this question I know how to disable mousewheel zoom in D3.js. How can I remap it to holding control button down plus mousewheel? Thanks.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Add a filter function to the zoom handler (https://github.com/d3/d3-zoom#zoom_filter).
In
d3.event
the elementctrlKey
(https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/ctrlKey) indicates if the control key was pressed or not.Returning
false
in the filter function ignores the event.I found a solution that does not need to modify the D3.js source.
I based my solution on this question: How to temporarily disable the zooming in d3.js
Instead of clicking on a button to enable/disable zooming, I used keydown/keyup events:
Here is a complete fiddle: https://jsfiddle.net/tabacof/dcbor8eL/3/