Always use un-scaled curve-time in divideLocations()

Fixes #1169
This commit is contained in:
Jürg Lehni 2016-09-23 06:55:12 -04:00
parent d3ac1b4c94
commit fbb0c59598
2 changed files with 9 additions and 10 deletions

View file

@ -28,9 +28,6 @@
*/ */
var CurveLocation = Base.extend(/** @lends CurveLocation# */{ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
_class: 'CurveLocation', _class: 'CurveLocation',
// Enforce creation of beans, as bean getters have hidden parameters.
// See #getSegment() below.
beans: true,
// DOCS: CurveLocation class description: add these back when the mentioned // DOCS: CurveLocation class description: add these back when the mentioned
// functioned have been added: {@link Path#split(location)} // functioned have been added: {@link Path#split(location)}
@ -134,8 +131,7 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
// still, otherwise assume it's the curve before segment2. // still, otherwise assume it's the curve before segment2.
function trySegment(segment) { function trySegment(segment) {
var curve = segment && segment.getCurve(); var curve = segment && segment.getCurve();
if (curve && (that._time = curve.getTimeOf(that._point)) if (curve && (that._time = curve.getTimeOf(that._point)) != null) {
!= null) {
// Fetch path again as it could be on a new one through split() // Fetch path again as it could be on a new one through split()
that._setCurve(curve); that._setCurve(curve);
that._segment = segment; that._segment = segment;

View file

@ -264,22 +264,25 @@ PathItem.inject(new function() {
prevTime; prevTime;
for (var i = locations.length - 1; i >= 0; i--) { for (var i = locations.length - 1; i >= 0; i--) {
var loc = locations[i]; var loc = locations[i],
// Call include() before retrieving _curve, because it might cause a // Retrieve curve-time before calling include(), because it may
// change in the cached location values (see #resolveCrossings()). // be changed to the scaled value after splitting previously.
// See CurveLocation#getCurve(), #resolveCrossings()
time = loc._time;
if (include) { if (include) {
if (!include(loc)) if (!include(loc))
continue; continue;
results.unshift(loc); results.unshift(loc);
} }
// Retrieve curve after calling include(), because it may cause a
// change in the cached location values, see above.
var curve = loc._curve, var curve = loc._curve,
time = loc._time,
origTime = time, origTime = time,
segment; segment;
if (curve !== prevCurve) { if (curve !== prevCurve) {
// This is a new curve, update noHandles setting. // This is a new curve, update noHandles setting.
noHandles = !curve.hasHandles(); noHandles = !curve.hasHandles();
} else if (prevTime >= tMin && prevTime <= tMax ) { } else if (prevTime > tMin) {
// Scale parameter when we are splitting same curve multiple // Scale parameter when we are splitting same curve multiple
// times, but only if splitting was done previously. // times, but only if splitting was done previously.
time /= prevTime; time /= prevTime;