From eaabf42b266c75fb1ee0dbe76fb1fb8366385394 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Fri, 19 Jan 2018 15:28:59 -0500
Subject: [PATCH] fix canvas_params interface

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

diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 5ab55a04d..c9f37448b 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -5199,11 +5199,12 @@ function gui_undo_menu(cid, undo_text, redo_text) {
 }
 
 // leverages the get_nw_window method in the callers...
-function canvas_params(nw_win, svg_elem)
+function canvas_params(nw_win)
 {
     // calculate the canvas parameters (svg bounding box and window geometry)
     // for do_getscroll and do_optimalzoom
-    var bbox, width, height, min_width, min_height, x, y;
+    var bbox, width, height, min_width, min_height, x, y, svg_elem;
+    svg_elem = nw_win.window.document.getElementById("patchsvg");
     bbox = svg_elem.getBBox();
     // We try to do Pd-extended style canvas origins. That is, coord (0, 0)
     // should be in the top-left corner unless there are objects with a
@@ -5255,7 +5256,7 @@ function do_getscroll(cid) {
     gui(cid).get_nw_window(function(nw_win) {
         var svg_elem = nw_win.window.document.getElementById("patchsvg");
         var { x: x, y: y, w: width, h: height,
-            mw: min_width, mh: min_height } = canvas_params(nw_win, svg_elem);
+            mw: min_width, mh: min_height } = canvas_params(nw_win);
         if (width < min_width) {
             width = min_width;
         }
@@ -5305,7 +5306,7 @@ function do_optimalzoom(cid, hflag, vflag) {
     // the window
     gui(cid).get_nw_window(function(nw_win) {
         var { x: x, y: y, w: width, h: height, mw: min_width, mh: min_height } =
-            canvas_params(cid);
+            canvas_params(nw_win);
         // Calculate the optimal horizontal and vertical zoom values,
         // using floor to always round down to the nearest integer. Note
         // that these may well be negative, if the viewport is too small
-- 
GitLab