From 8d5b970a61070f03253569efb405e159be56aa03 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Mon, 28 Sep 2009 20:22:19 +0000 Subject: [PATCH] Re-center canvas if the window is resized git-svn-id: http://svg-edit.googlecode.com/svn/trunk@723 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svg-editor.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index aadb5bd8..8372e05d 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -1221,12 +1221,8 @@ function svg_edit_setup() { setResolution(x * zoom, y * zoom); } - function setResolution(w, h, center) { - w-=0; h-=0; - $('#svgcanvas').css( { 'width': w, 'height': h } ); - $('#canvas_width').val(w); - $('#canvas_height').val(h); - + var centerCanvasIfNeeded = function() { + console.log('foo'); // this centers the canvas in the workarea if it's small enough var wa = {w: parseInt($('#workarea').css('width')), h: parseInt($('#workarea').css('height'))}; @@ -1238,6 +1234,17 @@ function svg_edit_setup() { if (wa.h > ca.h) { $('#svgcanvas').css({'top': (wa.h-ca.h)/2}); } + }; + + $(window).resize( centerCanvasIfNeeded ); + + function setResolution(w, h, center) { + w-=0; h-=0; + $('#svgcanvas').css( { 'width': w, 'height': h } ); + $('#canvas_width').val(w); + $('#canvas_height').val(h); + + centerCanvasIfNeeded(); if(center) { var w_area = $('#workarea');