diff --git a/editor/svg-editor.css b/editor/svg-editor.css index fc52bf80..35c5a389 100644 --- a/editor/svg-editor.css +++ b/editor/svg-editor.css @@ -30,7 +30,7 @@ #svg_editor #svgcanvas { display: inline-block; - background-color: #FFFFFF; + background-color: #A0A0A0; text-align: center; vertical-align: middle; width: 640px; diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 0d9bf2b0..3321b2c4 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -251,7 +251,7 @@ function svg_edit_setup() { var bb = z_info.bbox; $('#zoom').val(Math.round(zoomlevel*100)); // setResolution(res.w * zoomlevel, res.h * zoomlevel); - var scrLeft = bb.x * zoomlevel; + var scrLeft = bb.x * zoomlevel + $("svgcanvas").width()/2; var scrOffX = w_area.width()/2 - (bb.width * zoomlevel)/2; w_area[0].scrollLeft = Math.max(0,scrLeft - scrOffX) + Math.max(0,canvas_pos.left); var scrTop = bb.y * zoomlevel; @@ -1280,7 +1280,10 @@ function svg_edit_setup() { if(color == curPrefs.bg_color && url == curPrefs.bg_url) return; $.pref('bg_color', color); $.pref('bg_url', url); - $('#svgcanvas').css('background',color); + + // This should be done in svgcanvas.js for the borderRect fill + // $('#svgcanvas').css('background',color); + if(url) { if(!$('#background_img').length) { $('
') @@ -2324,11 +2327,11 @@ function svg_edit_setup() { } - var updateCanvas = function() { + var updateCanvas = function(center) { var w = workarea.width(), h = workarea.height(); var w_orig = w, h_orig = h; var zoom = svgCanvas.getZoom(); - var multi = (5*(zoom>1?zoom:1)); + var multi = (3*(zoom>1?zoom:1)); // Make the canvas bigger than the viewport w *= multi; h *= multi; @@ -2336,15 +2339,19 @@ function svg_edit_setup() { $("#svgcanvas").width(w).height(h); svgCanvas.updateCanvas(w, h); - var w_area = workarea; - var scroll_y = h/2 - h_orig/2; - var scroll_x = w/2 - w_orig/2; - w_area[0].scrollTop = scroll_y; - w_area[0].scrollLeft = scroll_x; +// if(center) { + var w_area = workarea; + var scroll_y = h/2 - h_orig/2; + var scroll_x = w/2 - w_orig/2; + w_area[0].scrollTop = scroll_y; + w_area[0].scrollLeft = scroll_x; +// } } // set starting resolution (centers canvas) // setResolution(640,480); - $(updateCanvas); + $(function() { + updateCanvas(true); + }); // var revnums = "svg-editor.js ($Rev$) "; // revnums += svgCanvas.getVersion(); diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 58c868f7..ffb4dde7 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -573,10 +573,10 @@ function BatchCommand(text) { 'y':'0', 'stroke-width':'1', 'stroke':'#000', - 'fill':'none', + 'fill':'#FFF', 'style':'pointer-events:none' }); - mgr.selectorParentGroup.appendChild(rect); + svgroot.insertBefore(rect, svgcontent); }; this.requestSelector = function(elem) { @@ -6375,7 +6375,9 @@ function BatchCommand(text) { assignAttributes(rect, { width: svgcontent.getAttribute('width') * current_zoom, - height: svgcontent.getAttribute('height') * current_zoom + height: svgcontent.getAttribute('height') * current_zoom, + x: x, + y: y }); selectorManager.selectorParentGroup.setAttribute("transform","translate(" + x + "," + y + ")");