server/src/main/webapp/static/js/renkan-publish.js
changeset 50 7b517a54b708
parent 47 267d67791e05
--- a/server/src/main/webapp/static/js/renkan-publish.js	Mon Dec 31 13:37:31 2012 +0100
+++ b/server/src/main/webapp/static/js/renkan-publish.js	Tue Jan 01 09:28:03 2013 +0100
@@ -905,9 +905,10 @@
 }
 
 Rkns.Renderer.Scene.prototype.autoScale = function() {
-    if (this.project.get("nodes").length) {
-        var _xx = this.project.get("nodes").map(function(_node) { return _node.get("position").x }),
-            _yy = this.project.get("nodes").map(function(_node) { return _node.get("position").y }),
+    var nodes = this.project.get("nodes")
+    if (nodes.length > 1) {
+        var _xx = nodes.map(function(_node) { return _node.get("position").x }),
+            _yy = nodes.map(function(_node) { return _node.get("position").y }),
             _minx = Math.min.apply(Math, _xx),
             _miny = Math.min.apply(Math, _yy),
             _maxx = Math.max.apply(Math, _xx),
@@ -916,6 +917,11 @@
         this.offset = paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(this.scale));
         this.redraw();
     }
+    if (nodes.length === 1) {
+        this.scale = 1;
+        this.offset = paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y]));
+        this.redraw();
+    }
 }
 
 Rkns.Renderer.Scene.prototype.toPaperCoords = function(_point) {