forcegraph: keyboard zoom using + -
This commit is contained in:
parent
144dba319e
commit
160100e6df
@ -469,6 +469,21 @@ define(["d3"], function (d3) {
|
||||
}
|
||||
}
|
||||
|
||||
function keyboardZoom(z) {
|
||||
return function () {
|
||||
var e = d3.event
|
||||
|
||||
if (e.altKey || e.ctrlKey || e.metaKey)
|
||||
return
|
||||
|
||||
if (e.keyCode === 43)
|
||||
animatePanzoom(z.translate(), z.scale() * 1.41)
|
||||
|
||||
if (e.keyCode === 45)
|
||||
animatePanzoom(z.translate(), z.scale() / 1.41)
|
||||
}
|
||||
}
|
||||
|
||||
el = document.createElement("div")
|
||||
el.classList.add("graph")
|
||||
self.div = el
|
||||
@ -479,10 +494,11 @@ define(["d3"], function (d3) {
|
||||
.translate([sidebar.getWidth(), 0])
|
||||
|
||||
canvas = d3.select(el)
|
||||
.call(zoomBehavior)
|
||||
.append("canvas")
|
||||
.attr("pointer-events", "all")
|
||||
.attr("tabindex", 1)
|
||||
.on("click", onClick)
|
||||
.on("keypress", keyboardZoom(zoomBehavior))
|
||||
.call(zoomBehavior)
|
||||
.call(draggableNode)
|
||||
.node()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user