restrict nodes to viewable area

alfred-data
Nils Schneider 2012-06-03 14:53:12 +02:00
parent 23b8651bf6
commit 88e7de0552
1 changed files with 5 additions and 0 deletions

View File

@ -315,6 +315,11 @@ d3.layout.force = function() {
} else { } else {
o.x -= (o.px - (o.px = o.x)) * friction; o.x -= (o.px - (o.px = o.x)) * friction;
o.y -= (o.py - (o.py = o.y)) * friction; o.y -= (o.py - (o.py = o.y)) * friction;
if (o.x < 0) o.x = 10;
if (o.x > size[0]) o.x = size[0] - 10;
if (o.y < 0) o.y = 10;
if (o.y > size[1]) o.y = size[1] - 10;
} }
} }