forcegraph: restore last panzoom on resetview
This commit is contained in:
parent
3a6d4855a9
commit
72dccaa51c
|
@ -18,6 +18,7 @@ define(["d3"], function (d3) {
|
|||
var highlightedLinks = []
|
||||
var nodes = []
|
||||
var unknownNodes = []
|
||||
var savedPanZoom
|
||||
|
||||
var draggedNode
|
||||
|
||||
|
@ -118,6 +119,12 @@ define(["d3"], function (d3) {
|
|||
|
||||
var translateP, scaleP
|
||||
|
||||
function onPanZoom() {
|
||||
savedPanZoom = {translate: zoomBehavior.translate(),
|
||||
scale: zoomBehavior.scale()}
|
||||
panzoom()
|
||||
}
|
||||
|
||||
function panzoom() {
|
||||
var translate = zoomBehavior.translate()
|
||||
var scale = zoomBehavior.scale()
|
||||
|
@ -196,7 +203,10 @@ define(["d3"], function (d3) {
|
|||
}
|
||||
|
||||
if (!nopanzoom)
|
||||
panzoomTo([0, 0], force.size())
|
||||
if (!savedPanZoom)
|
||||
panzoomTo([0, 0], force.size())
|
||||
else
|
||||
animatePanzoom(savedPanZoom.translate, savedPanZoom.scale)
|
||||
}
|
||||
|
||||
function drawLabel(d) {
|
||||
|
@ -465,7 +475,7 @@ define(["d3"], function (d3) {
|
|||
|
||||
zoomBehavior = d3.behavior.zoom()
|
||||
.scaleExtent([1 / 3, 3])
|
||||
.on("zoom", panzoom)
|
||||
.on("zoom", onPanZoom)
|
||||
.translate([sidebar.getWidth(), 0])
|
||||
|
||||
canvas = d3.select(el)
|
||||
|
|
Loading…
Reference in a new issue