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 highlightedLinks = []
|
||||||
var nodes = []
|
var nodes = []
|
||||||
var unknownNodes = []
|
var unknownNodes = []
|
||||||
|
var savedPanZoom
|
||||||
|
|
||||||
var draggedNode
|
var draggedNode
|
||||||
|
|
||||||
@ -118,6 +119,12 @@ define(["d3"], function (d3) {
|
|||||||
|
|
||||||
var translateP, scaleP
|
var translateP, scaleP
|
||||||
|
|
||||||
|
function onPanZoom() {
|
||||||
|
savedPanZoom = {translate: zoomBehavior.translate(),
|
||||||
|
scale: zoomBehavior.scale()}
|
||||||
|
panzoom()
|
||||||
|
}
|
||||||
|
|
||||||
function panzoom() {
|
function panzoom() {
|
||||||
var translate = zoomBehavior.translate()
|
var translate = zoomBehavior.translate()
|
||||||
var scale = zoomBehavior.scale()
|
var scale = zoomBehavior.scale()
|
||||||
@ -196,7 +203,10 @@ define(["d3"], function (d3) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!nopanzoom)
|
if (!nopanzoom)
|
||||||
panzoomTo([0, 0], force.size())
|
if (!savedPanZoom)
|
||||||
|
panzoomTo([0, 0], force.size())
|
||||||
|
else
|
||||||
|
animatePanzoom(savedPanZoom.translate, savedPanZoom.scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawLabel(d) {
|
function drawLabel(d) {
|
||||||
@ -465,7 +475,7 @@ define(["d3"], function (d3) {
|
|||||||
|
|
||||||
zoomBehavior = d3.behavior.zoom()
|
zoomBehavior = d3.behavior.zoom()
|
||||||
.scaleExtent([1 / 3, 3])
|
.scaleExtent([1 / 3, 3])
|
||||||
.on("zoom", panzoom)
|
.on("zoom", onPanZoom)
|
||||||
.translate([sidebar.getWidth(), 0])
|
.translate([sidebar.getWidth(), 0])
|
||||||
|
|
||||||
canvas = d3.select(el)
|
canvas = d3.select(el)
|
||||||
|
Loading…
Reference in New Issue
Block a user