Rau*_*l M 2 html javascript svg d3.js
我将此示例用作放大项目的基础,但我想将缩放限制为仅按钮和双击。理想情况下,使用滚轮应该只是继续向下滚动页面,而不是在鼠标悬停在 svg 上时放大它。任何帮助表示赞赏!
对于 D3 4.0,有两种方法可以防止 d3 zoom 响应滚轮事件。
A:
zoom.filter(function() { return !event.button && event.type !== 'wheel'; })
// the `!event.button` expression is from the default filter, according to
// doc for zoom.filter([filter])
Run Code Online (Sandbox Code Playgroud)
乙:
svg.on("wheel.zoom", null);
// according to doc for zoom(selection): Internally, the zoom behavior
// uses selection.on to bind the necessary event listeners for zooming.
// The listeners use the name .zoom
Run Code Online (Sandbox Code Playgroud)
仍然可以通过鼠标拖动来平移(翻译)。