forcegraph: do not animate pan/zoom on first router event
This commit is contained in:
parent
473734f2bb
commit
0780a83dd2
|
@ -6,6 +6,7 @@ define(["d3"], function (d3) {
|
|||
var zoomBehavior
|
||||
var force
|
||||
var el
|
||||
var doAnimation = false
|
||||
|
||||
function nodeName(d) {
|
||||
if (d.node && d.node.nodeinfo)
|
||||
|
@ -34,9 +35,13 @@ define(["d3"], function (d3) {
|
|||
zoomBehavior.scale(scale)
|
||||
zoomBehavior.translate(translate)
|
||||
|
||||
vis.transition().duration(500)
|
||||
.attr("transform", "translate(" + translate + ") " +
|
||||
"scale(" + scale + ")")
|
||||
var el = vis
|
||||
|
||||
if (doAnimation)
|
||||
el = el.transition().duration(500)
|
||||
|
||||
el.attr("transform", "translate(" + translate + ") " +
|
||||
"scale(" + scale + ")")
|
||||
}
|
||||
|
||||
function panzoom() {
|
||||
|
@ -236,6 +241,8 @@ define(["d3"], function (d3) {
|
|||
link.classed("highlight", false)
|
||||
|
||||
animatePanzoom([sidebar.getWidth(), 0], 1)
|
||||
|
||||
doAnimation = true
|
||||
}
|
||||
|
||||
self.gotoNode = function (d) {
|
||||
|
@ -248,6 +255,8 @@ define(["d3"], function (d3) {
|
|||
|
||||
if (n)
|
||||
panzoomTo([n.x, n.y], [n.x, n.y])
|
||||
|
||||
doAnimation = true
|
||||
}
|
||||
|
||||
self.gotoLink = function (d) {
|
||||
|
@ -263,6 +272,8 @@ define(["d3"], function (d3) {
|
|||
var y = d3.extent([l.source, l.target], function (d) { return d.y })
|
||||
panzoomTo([x[0], y[0]], [x[1], y[1]])
|
||||
}
|
||||
|
||||
doAnimation = true
|
||||
}
|
||||
|
||||
self.destroy = function () {
|
||||
|
|
Loading…
Reference in a new issue