diff --git a/src/path/CurveLocation.js b/src/path/CurveLocation.js index 6c0e8f2a..26f928b2 100644 --- a/src/path/CurveLocation.js +++ b/src/path/CurveLocation.js @@ -290,7 +290,7 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{ return this._distance; }, - // DOCS: divide(), split() + // DOCS: divide(), split(), getOffsetTo(loc) divide: function() { var curve = this.getCurve(), @@ -313,6 +313,21 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{ return res; }, + getOffsetTo: function(loc) { + var offset = null, + path = this.getPath(); + if (path && path === loc.getPath()) { + var offset1 = this.getOffset(), + offset2 = loc.getOffset(); + offset = offset2 - offset1; + if (offset < 0 && path._closed) { + // Wrap around the end of the path back to the beginning. + offset = path.getLength() - offset2 + offset1; + } + } + return offset; + }, + /** * Checks whether tow CurveLocation objects are describing the same location * on a path, by applying the same tolerances as elsewhere when dealing with