Reputation: 10622
I have a zoom functionality in my force layout. I only call it when the ctrl key is down like so :
.on("mousedown", function () {
if (d3.event.ctrlKey)
{
d3.select('#selectContainer').call(zoom).on("dblclick.zoom", null);
}
})
This works great, the first time but obviously, if I press ctrl whilst mouse is down, this will be attached to my element indefinitely. My question is how do I remove this if my mouse is down and I am not holding ctrl ?
Something like this (obviously doesn't work) :
.on("mousedown", function () {
if (d3.event.ctrlKey)
{
d3.select('#selectContainer').call(zoom).on("dblclick.zoom", null);
} else {
d3.select('#mainViewerContainerDiv').on("zoom", null);
}
})
Upvotes: 1
Views: 43
Reputation: 3004
replace zoom
with .zoom
d3.select('#mainViewerContainerDiv').on(".zoom", null);
Upvotes: 3