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# */{
_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
// 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.
function trySegment(segment) {
var curve = segment && segment.getCurve();
if (curve && (that._time = curve.getTimeOf(that._point))
!= null) {
if (curve && (that._time = curve.getTimeOf(that._point)) != null) {
// Fetch path again as it could be on a new one through split()
that._setCurve(curve);
that._segment = segment;

View file

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