mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Improve handling of _changed() events in Segment.
This commit is contained in:
parent
dc76ef144e
commit
847060e146
1 changed files with 21 additions and 18 deletions
|
@ -150,25 +150,27 @@ var Segment = Base.extend(/** @lends Segment# */{
|
||||||
},
|
},
|
||||||
|
|
||||||
_changed: function(point) {
|
_changed: function(point) {
|
||||||
if (!this._path)
|
var path = this._path;
|
||||||
|
if (!path)
|
||||||
return;
|
return;
|
||||||
// Delegate changes to affected curves if they exist. Check _curves
|
// Delegate changes to affected curves if they exist.
|
||||||
// first to make sure we're not creating it by calling this.getCurve().
|
var curves = path._curves,
|
||||||
var curve = this._path._curves && this.getCurve(),
|
index = this._index,
|
||||||
other;
|
curveIn, curveOut;
|
||||||
if (curve) {
|
if (curves) {
|
||||||
curve._changed();
|
// Updated the neighboring affected curves, depending on which point
|
||||||
// Get the other affected curve, which is the previous one for
|
// is changing.
|
||||||
// _point or _handleIn changing when this segment is _segment1 of
|
// TODO: Consider exposing these curves too, through #curveIn,
|
||||||
// the curve, for all other cases it's the next (e.g. _handleOut
|
// and #curveOut, next to #curve?
|
||||||
// when this segment is _segment2)
|
if ((!point || point === this._point || point === this._handleIn)
|
||||||
if (other = (curve[point == this._point
|
&& (curveIn = curves[index - 1]
|
||||||
|| point == this._handleIn && curve._segment1 == this
|
|| path._closed && curves[curves.length - 1]))
|
||||||
? 'getPrevious' : 'getNext']())) {
|
curveIn._changed();
|
||||||
other._changed();
|
if ((!point || point === this._point || point === this._handleOut)
|
||||||
}
|
&& (curveOut = curves[index]))
|
||||||
|
curveOut._changed();
|
||||||
}
|
}
|
||||||
this._path._changed(/*#=*/ Change.GEOMETRY);
|
path._changed(/*#=*/ Change.GEOMETRY);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -373,7 +375,8 @@ var Segment = Base.extend(/** @lends Segment# */{
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The curve that the segment belongs to.
|
* The curve that the segment belongs to. For the last segment of an open
|
||||||
|
* path, the previous segment is returned.
|
||||||
*
|
*
|
||||||
* @type Curve
|
* @type Curve
|
||||||
* @bean
|
* @bean
|
||||||
|
|
Loading…
Reference in a new issue