javascript - Unregister zoom listener and restore scroll ability in D3.js -


i'm working d3.js. code register zoom listener svg tag

var zoomlistener = d3.behavior.zoom().scaleextent([0.1, 3]).on("zoom", zoom); function zoom() {   vis.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")"); } svg.call(zoomlistener) 

now when scroll mouse on svg element, zoomed. when unbind zoom event this

zoomlistener.on("zoom", null); 

only svg not zoomed cannot scroll page while mouse on svg element.

how unbind zoom listener , restore scroll ability mouse? thanks!

to disable zoom behaviour, need unregister event handlers has installed on element you've called on:

svg.on("mousedown.zoom", null); svg.on("mousemove.zoom", null); svg.on("dblclick.zoom", null); svg.on("touchstart.zoom", null); svg.on("wheel.zoom", null); svg.on("mousewheel.zoom", null); svg.on("mozmousepixelscroll.zoom", null); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -