From 11f858ea0e61bb3dda817a598d3d605ed6266402 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Wed, 24 Jun 2015 23:25:05 -0400
Subject: [PATCH] set correct svg viewBox and height/width for new patches

---
 pd/nw/pdgui.js | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 3e2d9a953..89abc9f96 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -3547,14 +3547,23 @@ function gui_undo_menu(cid, undo_text, redo_text) {
 function gui_canvas_getscroll(cid) {
     var svg = get_item(cid, 'patchsvg');
     var bbox = svg.getBBox();
+    var width = bbox.x > 0 ? bbox.x + bbox.width : bbox.width,
+        height = bbox.y > 0 ? bbox.y + bbox.height : bbox.height;
+    if (width === 0) {
+        width = patchwin[cid].window.innerWidth;
+    }
+    if (height === 0) {
+        height = patchwin[cid].window.innerHeight;
+    }
     configure_item(svg, {
         viewBox: [bbox.x > 0 ? 0 : bbox.x,
                   bbox.y > 0 ? 0 : bbox.y,
-                  bbox.x > 0 ? bbox.x + bbox.width : bbox.width,
-                  bbox.y > 0 ? bbox.y + bbox.height: bbox.height].join(" ")
+                  width,
+                  height] 
+                  .join(" ")
     });
-    svg.width.baseVal.valueAsString = bbox.x > 0 ? bbox.x + bbox.width : bbox.width;
-    svg.height.baseVal.valueAsString = bbox.y > 0 ? bbox.y + bbox.height : bbox.height;
+    svg.width.baseVal.valueAsString = width;
+    svg.height.baseVal.valueAsString = height;
     console.log("x is " + bbox.x);
     console.log("y is " + bbox.x);
     console.log("width is " + bbox.width);
-- 
GitLab