Merge Path#_getOffset() with CurveLocation#getOffset()

This commit is contained in:
Jürg Lehni 2015-10-23 19:57:25 +02:00
parent e3f065277e
commit c8cc653004
2 changed files with 9 additions and 19 deletions

View file

@ -212,9 +212,15 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
getOffset: function() {
var offset = this._offset;
if (offset == null) {
var path = this.getPath();
offset = this._offset = path ? path._getOffset(this)
: this.getCurveOffset();
offset = 0;
var path = this.getPath(),
index = this.getIndex();
if (path && index != null) {
var curves = path.getCurves();
for (var i = 0; i < index; i++)
offset += curves[i].getLength();
}
this._offset = offset += this.getCurveOffset();
}
return offset;
},

View file

@ -1680,22 +1680,6 @@ var Path = PathItem.extend(/** @lends Path# */{
// See #getLocationOf(), #getNearestLocation(), #getNearestPoint()
beans: false,
_getOffset: function(location) {
var index = location && location.getIndex();
if (index != null) {
var curves = this.getCurves(),
offset = 0;
for (var i = 0; i < index; i++)
offset += curves[i].getLength();
var curve = curves[index],
parameter = location.getParameter();
if (parameter > 0)
offset += curve.getPartLength(0, parameter);
return offset;
}
return null;
},
/**
* {@grouptitle Positions on Paths and Curves}
*