forcegraph: fix translation of keyboard zoom
This commit is contained in:
parent
189172ac65
commit
301630e47e
|
@ -469,6 +469,18 @@ define(["d3"], function (d3) {
|
|||
}
|
||||
}
|
||||
|
||||
function zoom(z, scale) {
|
||||
var size = getSize()
|
||||
var newSize = [size[0] / scale, size[1] / scale]
|
||||
|
||||
var sidebarWidth = sidebar.getWidth()
|
||||
var delta = [size[0] - newSize[0], size[1] - newSize[1]]
|
||||
var translate = z.translate()
|
||||
var translateNew = [sidebarWidth + (translate[0] - sidebarWidth - delta[0] / 2) * scale, (translate[1] - delta[1] / 2) * scale]
|
||||
|
||||
animatePanzoom(translateNew, z.scale() * scale)
|
||||
}
|
||||
|
||||
function keyboardZoom(z) {
|
||||
return function () {
|
||||
var e = d3.event
|
||||
|
@ -477,10 +489,10 @@ define(["d3"], function (d3) {
|
|||
return
|
||||
|
||||
if (e.keyCode === 43)
|
||||
animatePanzoom(z.translate(), z.scale() * 1.41)
|
||||
zoom(z, 1.41)
|
||||
|
||||
if (e.keyCode === 45)
|
||||
animatePanzoom(z.translate(), z.scale() / 1.41)
|
||||
zoom(z, 1 / 1.41)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue