mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Address remaining issue with curves being wrongly linked up after adding new segments.
This commit is contained in:
parent
30e6835745
commit
1fc17766fb
1 changed files with 6 additions and 5 deletions
|
@ -385,7 +385,7 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
curves = this._curves,
|
curves = this._curves,
|
||||||
amount = segs.length,
|
amount = segs.length,
|
||||||
append = index == null,
|
append = index == null,
|
||||||
from = append ? segments.length : index;
|
index = append ? segments.length : index;
|
||||||
// Scan through segments to add first, convert if necessary and set
|
// Scan through segments to add first, convert if necessary and set
|
||||||
// _path and _index references on them.
|
// _path and _index references on them.
|
||||||
for (var i = 0; i < amount; i++) {
|
for (var i = 0; i < amount; i++) {
|
||||||
|
@ -395,7 +395,7 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
if (segment._path)
|
if (segment._path)
|
||||||
segment = segs[i] = segment.clone();
|
segment = segs[i] = segment.clone();
|
||||||
segment._path = this;
|
segment._path = this;
|
||||||
segment._index = from + i;
|
segment._index = index + i;
|
||||||
// If parts of this segment are selected, adjust the internal
|
// If parts of this segment are selected, adjust the internal
|
||||||
// _selectedSegmentState now
|
// _selectedSegmentState now
|
||||||
if (segment._selectionState)
|
if (segment._selectionState)
|
||||||
|
@ -406,9 +406,9 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
segments.push.apply(segments, segs);
|
segments.push.apply(segments, segs);
|
||||||
} else {
|
} else {
|
||||||
// Insert somewhere else
|
// Insert somewhere else
|
||||||
segments.splice.apply(segments, [from, 0].concat(segs));
|
segments.splice.apply(segments, [index, 0].concat(segs));
|
||||||
// Adjust the indices of the segments above.
|
// Adjust the indices of the segments above.
|
||||||
for (var i = from + amount, l = segments.length; i < l; i++)
|
for (var i = index + amount, l = segments.length; i < l; i++)
|
||||||
segments[i]._index = i;
|
segments[i]._index = i;
|
||||||
}
|
}
|
||||||
// Keep the curves list in sync all the time in case it was requested
|
// Keep the curves list in sync all the time in case it was requested
|
||||||
|
@ -417,7 +417,8 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
var total = this._countCurves(),
|
var total = this._countCurves(),
|
||||||
// If we're adding a new segment to the end of an open path,
|
// If we're adding a new segment to the end of an open path,
|
||||||
// we need to step one index down to get its curve.
|
// we need to step one index down to get its curve.
|
||||||
start = from === total ? from - 1 : from,
|
from = index === total ? index - 1 : index,
|
||||||
|
start = from,
|
||||||
to = Math.min(from + amount, total);
|
to = Math.min(from + amount, total);
|
||||||
if (segs._curves) {
|
if (segs._curves) {
|
||||||
// Reuse removed curves.
|
// Reuse removed curves.
|
||||||
|
|
Loading…
Reference in a new issue