You can selectively disable zooming by stopping the propagation of the mousedown event. Here, a mousedown listener restricts panning to left click, so that panning is not initiated when the context menu opens. (On OS X, the context menu also appears on control-mousedown, so this is prevented as well.)
The mousedown listener and zoom behavior are registered on the same element, so d3.event.stopImmmediatePropagation is needed to prevent the zoom behavior from hearing the mousedown event. Alternatively, you could use a capturing listener on a parent element, or a non-capturing listener on a child element.
On each mousedown, a small red pulse visually indicates that the event was stopped, while a green pulse indicates that the zoom behavior was triggered.