score:0
Aug's answer pointed me in the right direction but just in case someone needed more detail here's how I resolved my issue. It
I am already using double click events for other user needs. So there are specific instances in which I do not want the double click zoom to occur. This code worked for me in d3 version 5.15.x
D3.select('svg')
.call(D3.zoom()
.scaleExtent([-5, 8])
.extent([[0, 0], [300, 300]])
.on('zoom', () => {
D3.selectAll('g')
.attr('transform', D3.event.transform);
this.updateAfterInit(this.root);
})
.filter(() => {
const foundNode = this.N.findNodeByID(D3.event.srcElement.id.split('_')[1])
if ( !!foundNode && D3.event.type === 'dblclick' && foundNode.data.type === 'SearchRelationspec') {
return false;
} else {
return !D3.event.target.classList.contains('drawarea') && D3.event.type === 'dblclick';
}
})
score:1
Why don't you do the same thing you did with your images? You can use your custom code with stopPropagation:
d3.select('svg').selectAll('circle').on('dblclick', () => {
event.stopPropagation();
// your code here
});
This will allow you to harness double click you want without propagating the double click to the svg.
score:2
I think you have two options. You can do what you suggested which was to utilize event delegation check if the event.target
is a circle
element. Just be aware in d3
you may need to hook into d3.event
instead to access the target
.
d3.zoom
also provides a way to filter with the zoom.filter
which similarly you can pass in the condition you want to hook into i.e. checking if d3.event.target
is a circle
.
EDIT: It sounds like you are using d3.v3 which from the API doesn't support as much to handle these use cases. I highly suggest upgrading.
Source: stackoverflow.com
Related Query
- How to disable double click zoom for d3.behavior.zoom?
- In D3, How to disable double click zoom conditionally?
- How can I make double click event on node in d3.js?
- How to disable brush selection on right click in d3.js
- How to use mouse click and drag to zoom in D3
- How can I disable panning on left click in d3
- d3 maps: how to disable zoom on scrollwheel but retain panning by dragging
- how to distinguish between single mouse click and double click on same node element in d3 js
- d3 zoom with button and double click but don't zoom with with scroll wheel
- How can I detect double click on brush object?
- How to achieve double click in Tree in D3.js?
- D3: how to disable zoom on icons with background image?
- How to disable click event after drag stop in d3.js tree
- d3 zoom in on svg on click, zoom out on next double click
- How do I disable my zoom functionality in D3.js?
- D3 chart: how to obtain x, y values on double click event
- d3.js Zoomable Circle Packing - How to prevent additional click events until zoom is complete
- D3 - Setting the zoom scale of Double Click
- d3 click coordinates are relative to page not svg - how to translate them (Chrome error)
- How to disable pan for d3.behavior.zoom?
- How to add a click event on nvd3.js graph
- How to disable animation in a force-directed graph?
- How to disable legend in nvd3 or limit it's size
- How to disable some streams by default in a nvd3 Simple Line Chart?
- How to show full text when zoom in & truncate it when zoom out
- how to know the current Zoom level in D3.js
- How do I specify the initial zoom level in D3?
- D3js: How do I clear the zoom scale set by the d3.zoom event?
- How to temporarily disable the zooming in d3.js
- How to reset Zoom in d3.js?
More Query from same tag
- How to create a new array using the data from the old one?
- D3.js <div> not working
- Normalize the Graph axes in NVD3 Line with focus chart
- How to append a text element with inline tspan children?
- React - Warning: React.createElement: type should not be null, undefined, boolean, or number
- How to get d3 treemap cell text to wrap and not overflow other cells
- Why do the y axis values shift up from real point in line chart?
- how to install python for using d3 charts at windows
- How do I retrieve an array from a csv file in javascript using d3?
- bisectLeft function does not work if the second parameter is numerical
- d3js update and maintain structure of visualization
- Text appended to path does not show
- Alter first vertical grid line in nvd3
- How to get d3.js tree layout to sort nodes alphabetically?
- how to highlight over lap beetween rectangles in d3 js
- Why does d3.json return "null"?
- D3.js tree with odd number of vertices, edges not shown
- draw circle in the end of SVG path in realtime line chart D3.js
- Multiple Assignments in JavaScript Expression and Syntax Explanation
- How can I define a maximal amount of ticks in a d3.svg.axis
- D3 updating bar chart with new data set cause update issue
- For loop does not work in D3.js
- How to summarize an array with group and rollup from d3-array?
- D3.js v4: Text appended to partition layout but not showing up
- dc.js - multiple lineChart based on separate categories in single csv file
- Cannot run python SImpleHTTPServer on windows 10 for d3.js testing (issue changing environment variable)
- Integrating button to change divergent bar chart in d3.js?
- d3 chart show multiple label in one slice on mouse hover
- Beginner in d3, making US county map
- How to drag complete svg with d3js?