Remove fix that cloned path segments and add tests to show it works

This commit is contained in:
Philip Rogers
2016-02-21 17:13:40 -08:00
parent e625a2b434
commit e826d3ff19
2 changed files with 147 additions and 28 deletions

View File

@@ -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);