From ae533338a1eba7a3657054826e40537c000fc20e Mon Sep 17 00:00:00 2001 From: StalderT Date: Sat, 16 Jan 2016 19:42:15 +0100 Subject: [PATCH 1/4] Update svgcanvas.js correct https://github.com/SVG-Edit/svgedit/issues/54 --- editor/svgcanvas.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 765362b6..eb026299 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -554,12 +554,14 @@ var getIntersectionList = this.getIntersectionList = function(rect) { } var resultList = null; - if (typeof(svgroot.getIntersectionList) == 'function') { - // Offset the bbox of the rubber box by the offset of the svgcontent element. - rubberBBox.x += parseInt(svgcontent.getAttribute('x'), 10); - rubberBBox.y += parseInt(svgcontent.getAttribute('y'), 10); + if (!svgedit.browser.isIE) { + if (typeof(svgroot.getIntersectionList) == 'function') { + // Offset the bbox of the rubber box by the offset of the svgcontent element. + rubberBBox.x += parseInt(svgcontent.getAttribute('x'), 10); + rubberBBox.y += parseInt(svgcontent.getAttribute('y'), 10); - resultList = svgroot.getIntersectionList(rubberBBox, parent); + resultList = svgroot.getIntersectionList(rubberBBox, parent); + } } if (resultList == null || typeof(resultList.item) != 'function') { From 88ef7b02cc1325451e86a4298f9cc3d917f437de Mon Sep 17 00:00:00 2001 From: Magne Bratseth Date: Wed, 10 Feb 2016 09:38:43 +0100 Subject: [PATCH 2/4] It seems some browsers require objects passed to getInsectionList to actually be of the correct type --- editor/svgcanvas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 3f2cf464..4770c8af 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -549,7 +549,7 @@ var getIntersectionList = this.getIntersectionList = function(rect) { var rubberBBox; if (!rect) { rubberBBox = rubberBox.getBBox(); - var o, bb = {}; + var o, bb = svgcontent.createSVGRect(); for (o in rubberBBox) { bb[o] = rubberBBox[o] / current_zoom; From 948ba30214d9fe735e4f48e129b40ddefd03103f Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Sun, 14 Feb 2016 13:42:28 -0800 Subject: [PATCH 3/4] Fix browser.js error messages when testing whether replaceItem and insertItemBefore work, since paths must start with M commands --- editor/browser.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/browser.js b/editor/browser.js index dc6ee6eb..4a70f424 100644 --- a/editor/browser.js +++ b/editor/browser.js @@ -59,7 +59,7 @@ var supportsPathReplaceItem_ = (function() { var seglist = path.pathSegList; var seg = path.createSVGPathSegLinetoAbs(5,5); try { - seglist.replaceItem(seg, 0); + seglist.replaceItem(seg, 1); return true; } catch(err) {} return false; @@ -71,7 +71,7 @@ var supportsPathInsertItemBefore_ = (function() { var seglist = path.pathSegList; var seg = path.createSVGPathSegLinetoAbs(5,5); try { - seglist.insertItemBefore(seg, 0); + seglist.insertItemBefore(seg, 1); return true; } catch(err) {} return false; From e826d3ff190fcebf7ba3c3b9b66e916436f6b77d Mon Sep 17 00:00:00 2001 From: Philip Rogers Date: Sun, 21 Feb 2016 17:13:40 -0800 Subject: [PATCH 4/4] Remove fix that cloned path segments and add tests to show it works --- editor/path.js | 43 +++++---------- test/path_test.html | 132 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 28 deletions(-) diff --git a/editor/path.js b/editor/path.js index 75ad3c7e..ccdf5486 100644 --- a/editor/path.js +++ b/editor/path.js @@ -478,16 +478,12 @@ svgedit.path.Segment.prototype.update = function(full) { svgedit.path.Segment.prototype.move = function(dx, dy) { var cur_pts, item = this.item; - // fix for path tool dom breakage, amending item does bad things now, so we take a copy and use that. Can probably improve to just take a shallow copy of object - var cloneItem = $.extend({}, item); - - if (this.ctrlpts) { - cur_pts = [cloneItem.x += dx, cloneItem.y += dy, - cloneItem.x1, cloneItem.y1, cloneItem.x2 += dx, cloneItem.y2 += dy]; - } else { - cur_pts = [cloneItem.x += dx, cloneItem.y += dy]; - } - //fix + if (this.ctrlpts) { + cur_pts = [item.x += dx, item.y += dy, + item.x1, item.y1, item.x2 += dx, item.y2 += dy]; + } else { + cur_pts = [item.x += dx, item.y += dy]; + } svgedit.path.replacePathSeg(this.type, this.index, cur_pts); @@ -526,16 +522,12 @@ svgedit.path.Segment.prototype.setLinked = function(num) { } var item = seg.item; - // fix for path tool dom breakage, amending item does bad things now, so we take a copy and use that. Can probably improve to just take a shallow copy of object - var cloneItem = $.extend({}, item); - cloneItem['x' + anum ] = pt.x + (pt.x - this.item['x' + num]); - cloneItem['y' + anum ] = pt.y + (pt.y - this.item['y' + num]); - - var pts = [cloneItem.x, cloneItem.y, - cloneItem.x1, cloneItem.y1, - cloneItem.x2, cloneItem.y2]; - //end fix + item['x' + anum ] = pt.x + (pt.x - this.item['x' + num]); + item['y' + anum ] = pt.y + (pt.y - this.item['y' + num]); + var pts = [item.x, item.y, + item.x1, item.y1, + item.x2, item.y2]; svgedit.path.replacePathSeg(seg.type, seg.index, pts); seg.update(true); @@ -543,16 +535,11 @@ svgedit.path.Segment.prototype.setLinked = function(num) { svgedit.path.Segment.prototype.moveCtrl = function(num, dx, dy) { var item = this.item; + item['x' + num] += dx; + item['y' + num] += dy; - // fix for path tool dom breakage, amending item does bad things now, so we take a copy and use that. Can probably improve to just take a shallow copy of object - var cloneItem = $.extend({}, item); - cloneItem['x' + num] += dx; - cloneItem['y' + num] += dy; - - var pts = [cloneItem.x,cloneItem.y, - cloneItem.x1,cloneItem.y1, cloneItem.x2,cloneItem.y2]; - // end fix - + var pts = [item.x,item.y, + item.x1,item.y1, item.x2,item.y2]; svgedit.path.replacePathSeg(this.type, this.index, pts); this.update(true); diff --git a/test/path_test.html b/test/path_test.html index 20c40d06..3c80708e 100644 --- a/test/path_test.html +++ b/test/path_test.html @@ -6,6 +6,9 @@ + + +