Permalink
Browse files

Fix for issue #9 in jacomyal/sigma.js, solved by clamping displayX an…

…d displayY after resizing according to maxNodeSize
  • Loading branch information...
1 parent 8331c7e commit 15424148676fc4a40f64d7150b34d339a03dd743 @Raibaz Raibaz committed Apr 4, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 src/core/graph.js
View
@@ -439,6 +439,11 @@ function Graph() {
Math.min(w / Math.max(xMax - xMin, 1),
h / Math.max(yMax - yMin, 1));
+ xMax += self.p.maxNodeSize;
+ xMin -= self.p.maxNodeSize;
+ yMax += self.p.maxNodeSize;
+ yMin -= self.p.maxNodeSize;
+
// Size homothetic parameters:
var a, b;
if (!self.p.maxNodeSize && !self.p.minNodeSize) {
@@ -471,6 +476,17 @@ function Graph() {
if (!node['fixed']) {
node['displayX'] = (node['x'] - (xMax + xMin) / 2) * scale + w / 2;
node['displayY'] = (node['y'] - (yMax + yMin) / 2) * scale + h / 2;
+
+ if(node['displayX'] < self.p.maxNodeSize) {
+ node['displayX'] += self.p.maxNodeSize;
+ } else if(node['displayX'] >= (w - self.p.maxNodeSize)) {
+ node['displayX'] -= self.p.maxNodeSize;
+ }
+ if(node['displayY'] < self.p.maxNodeSize) {
+ node['displayY'] += self.p.maxNodeSize;
+ } else if(node['displayY'] >= (h - self.p.maxNodeSize)) {
+ node['displayY'] -= self.p.maxNodeSize;
+ }
}
});

0 comments on commit 1542414

Please sign in to comment.