The Unhelpful Github discussion made me ask this question here:
After the transition to the new v4.0 D3, it seems that using d3.zoom() blocks some events , for example:
Call:
svg.call(d3.zoom() .scaleExtent([1, 40]) .translateExtent([[-100, -100], [width + 90, height + 100]]) .on("zoom", zoomed));
And then this:
document.querySelector('svg').addEventListener('mouseup', function(){ alert(1) })
Will not warn anything when clicked anywhere SVG.
I really don't want to do:
window.addEventListener("mouseup", function(e){ if( [target or target parent is the specific SVG element] ){
Because this will result in a global mouseup event, which does not contain names, in the window (this method seems to work only with the window object), and this event can be deleted somewhere else or it will happen several times. (Encapsulating it is not easy, or I just donβt know how to do it).
Any better ideas on how to capture mouseup events on SVG?
In connection with my other question: Namespace capture event
Update:
With Mark's answer, here's a working demo
vsync source share