thatOneGuy
thatOneGuy

Reputation: 10622

How to remove zoom capability after you set it in D3?

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

Answers (1)

murli2308
murli2308

Reputation: 3004

replace zoom with .zoom

d3.select('#mainViewerContainerDiv').on(".zoom", null);

Upvotes: 3

Related Questions