Skip to content

Commit

Permalink
fixing path edit bug
Browse files Browse the repository at this point in the history
  • Loading branch information
methodofaction committed Jul 6, 2015
1 parent 4b829a1 commit 2c7c5be
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
30 changes: 18 additions & 12 deletions editor/src/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,14 @@ svgedit.path.Segment.prototype.update = function(full) {

svgedit.path.Segment.prototype.move = function(dx, dy) {
var item = this.item;
if(this.ctrlpts) {
var cur_pts = [item.x += dx, item.y += dy,
item.x1, item.y1, item.x2 += dx, item.y2 += dy];
} else {
var cur_pts = [item.x += dx, item.y += 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);
var cur_pts = (this.ctrlpts)
? [cloneItem.x += dx, cloneItem.y += dy,
cloneItem.x1, cloneItem.y1,
cloneItem.x2 += dx, cloneItem.y2 += dy]
: [cloneItem.x += dx, cloneItem.y += dy];

svgedit.path.replacePathSeg(this.type, this.index, cur_pts);

if(this.next && this.next.ctrlpts) {
Expand Down Expand Up @@ -514,18 +516,22 @@ svgedit.path.Segment.prototype.setLinked = function(num) {
}

var item = seg.item;
item['x' + anum] = pt.x + pt.x - this.item['x' + num];
item['y' + anum] = pt.y + pt.y - this.item['y' + num];
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
];

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

svgedit.path.Segment.prototype.moveCtrl = function(num, dx, dy) {
var item = this.item;
var item = $.extend({}, this.item);

item['x' + num] += dx;
item['y' + num] += dy;
Expand Down
30 changes: 18 additions & 12 deletions method-draw/src/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,14 @@ svgedit.path.Segment.prototype.update = function(full) {

svgedit.path.Segment.prototype.move = function(dx, dy) {
var item = this.item;
if(this.ctrlpts) {
var cur_pts = [item.x += dx, item.y += dy,
item.x1, item.y1, item.x2 += dx, item.y2 += dy];
} else {
var cur_pts = [item.x += dx, item.y += 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);
var cur_pts = (this.ctrlpts)
? [cloneItem.x += dx, cloneItem.y += dy,
cloneItem.x1, cloneItem.y1,
cloneItem.x2 += dx, cloneItem.y2 += dy]
: [cloneItem.x += dx, cloneItem.y += dy];

svgedit.path.replacePathSeg(this.type, this.index, cur_pts);

if(this.next && this.next.ctrlpts) {
Expand Down Expand Up @@ -514,18 +516,22 @@ svgedit.path.Segment.prototype.setLinked = function(num) {
}

var item = seg.item;
item['x' + anum] = pt.x + pt.x - this.item['x' + num];
item['y' + anum] = pt.y + pt.y - this.item['y' + num];
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
];

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

svgedit.path.Segment.prototype.moveCtrl = function(num, dx, dy) {
var item = this.item;
var item = $.extend({}, this.item);

item['x' + num] += dx;
item['y' + num] += dy;
Expand Down

0 comments on commit 2c7c5be

Please sign in to comment.