mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Pass Item.NO_INSERT to internally created paths and do not rely on insertAbove() to always return a result.
If `this` itself is not in the DOM, insertAbove() will fail.
This commit is contained in:
parent
1fc17766fb
commit
fcd4fe824c
2 changed files with 6 additions and 3 deletions
|
@ -334,7 +334,8 @@ new function() { // Injection scope for PostScript-like drawing functions
|
|||
moveTo: function(/* point */) {
|
||||
var current = getCurrentPath(this),
|
||||
// Reuse current path if nothing was added yet
|
||||
path = current && current.isEmpty() ? current : new Path();
|
||||
path = current && current.isEmpty() ? current
|
||||
: new Path(Item.NO_INSERT);
|
||||
if (path !== current)
|
||||
this.addChild(path);
|
||||
path.moveTo.apply(path, arguments);
|
||||
|
|
|
@ -1241,10 +1241,12 @@ var Path = PathItem.extend(/** @lends Path# */{
|
|||
// will happen below.
|
||||
path = this;
|
||||
} else {
|
||||
path = new Path(Item.NO_INSERT);
|
||||
// Pass true for _preserve, in case of CompoundPath, to avoid
|
||||
// reversing of path direction, which would mess with segs!
|
||||
// reversing of path direction, which would mess with segments!
|
||||
path.insertAbove(this, true);
|
||||
// Use _clone to copy over all other attributes, including style
|
||||
path = this._clone(new Path().insertAbove(this, true));
|
||||
this._clone(path);
|
||||
}
|
||||
path._add(segs, 0);
|
||||
// Add dividing segment again. In case of a closed path, that's the
|
||||
|
|
Loading…
Reference in a new issue