From 9b04d4689ec7f343b91ababec3c7f18ea003e7de Mon Sep 17 00:00:00 2001 From: Alexis Deveria Date: Tue, 6 Apr 2010 13:12:54 +0000 Subject: [PATCH] Applied patch by aobjects, fixes issue 512 git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1504 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index c43f3864..87569356 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -6742,6 +6742,8 @@ function BatchCommand(text) { svgcontent.setAttribute('width', x); svgcontent.setAttribute('height', y); + this.contentW = x; + this.contentH = y; batchCmd.addSubCommand(new ChangeElementCommand(svgcontent, {"width":w, "height":h})); svgcontent.setAttribute("viewBox", [0, 0, x/current_zoom, y/current_zoom].join(' ')); @@ -7866,23 +7868,29 @@ function BatchCommand(text) { }; } + this.contentW = this.getResolution().w; + this.contentH = this.getResolution().h; + this.updateCanvas = function(w, h, w_orig, h_orig) { svgroot.setAttribute("width", w); svgroot.setAttribute("height", h); var bg = $('#canvasBackground')[0]; var old_x = svgcontent.getAttribute('x'); var old_y = svgcontent.getAttribute('y'); - var x = (w/2 - svgcontent.getAttribute('width')*current_zoom/2); - var y = (h/2 - svgcontent.getAttribute('height')*current_zoom/2); - + var x = (w/2 - this.contentW*current_zoom/2); + var y = (h/2 - this.contentH*current_zoom/2); + assignAttributes(svgcontent, { + width: this.contentW*current_zoom, + height: this.contentH*current_zoom, 'x': x, - 'y': y + 'y': y, + "viewBox" : "0 0 " + this.contentW + " " + this.contentH }); assignAttributes(bg, { - width: svgcontent.getAttribute('width') * current_zoom, - height: svgcontent.getAttribute('height') * current_zoom, + width: svgcontent.getAttribute('width'), + height: svgcontent.getAttribute('height'), x: x, y: y });