mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Implement caching for CurveLocation#curveOffset.
This commit is contained in:
parent
f089c3c620
commit
ee48e6cd03
1 changed files with 9 additions and 4 deletions
|
@ -121,7 +121,7 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
|
||||||
if (path && path._version !== this._version) {
|
if (path && path._version !== this._version) {
|
||||||
// If the path's segments have changed, clear the cached time and
|
// If the path's segments have changed, clear the cached time and
|
||||||
// offset values and force re-fetching of the correct curve.
|
// offset values and force re-fetching of the correct curve.
|
||||||
this._time = this._offset = this._curve = null;
|
this._time = this._offset = this._curveOffset = this._curve = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If path is out of sync, access current curve objects through segment1
|
// If path is out of sync, access current curve objects through segment1
|
||||||
|
@ -232,9 +232,14 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
getCurveOffset: function() {
|
getCurveOffset: function() {
|
||||||
var curve = this.getCurve(),
|
var offset = this._curveOffset;
|
||||||
time = this.getTime();
|
if (offset == null) {
|
||||||
return time != null && curve && curve.getPartLength(0, time);
|
var curve = this.getCurve(),
|
||||||
|
time = this.getTime();
|
||||||
|
this._curveOffset = offset = time != null && curve
|
||||||
|
&& curve.getPartLength(0, time);
|
||||||
|
}
|
||||||
|
return offset;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue