diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 78b94137..dcffcfad 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -2474,11 +2474,19 @@ $('#image_save_opts input').val([curPrefs.img_save]); docprops = false; }; + + var win_wh = {width:$(window).width(), height:$(window).height()}; - // TODO: add canvas-centering code in here $(window).resize(function(evt) { - if (!editingsource) return; - properlySourceSizeTextArea(); + if (editingsource) { + properlySourceSizeTextArea(); + } + + $.each(win_wh, function(type, val) { + var curval = $(window)[type](); + workarea[0]['scroll' + (type==='width'?'Left':'Top')] -= (curval - val)/2; + win_wh[type] = curval; + }); }); $('#url_notice').click(function() { @@ -3545,9 +3553,11 @@ 'url': url, 'dataType': 'text', success: svgCanvas.setSvgString, - error: function(xhr) { + error: function(xhr, stat, err) { if(xhr.responseText) { svgCanvas.setSvgString(xhr.responseText); + } else { + $.alert("Unable to load from URL. Error: \n"+err+''); } } }); diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 7213b30b..68625c09 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -4790,6 +4790,9 @@ function BatchCommand(text) { this.addSeg = function(index) { // Adds a new segment var seg = p.segs[index]; + + if(!seg.prev) return; + var prev = seg.prev; var new_x = (seg.item.x + prev.item.x) / 2;