restrict nodes to viewable area
This commit is contained in:
parent
23b8651bf6
commit
88e7de0552
|
@ -315,6 +315,11 @@ d3.layout.force = function() {
|
|||
} else {
|
||||
o.x -= (o.px - (o.px = o.x)) * 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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue