From 46abb949df96b54c9f27ff067411eabe1cb0c6ee Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Wed, 11 Dec 2013 16:50:23 +0900 Subject: [PATCH 1/2] Fix motion path effect when sampling at end of interval. The first two changes aren't strictly necessary and are just sanity checks. --- web-animations.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web-animations.js b/web-animations.js index c573c4ce..f3d54889 100644 --- a/web-animations.js +++ b/web-animations.js @@ -1694,8 +1694,11 @@ PathAnimationEffect.prototype = createObject(AnimationEffect.prototype, { } }, _sample: function(timeFraction, currentIteration, target) { + if (timeFraction === null) + return; // TODO: Handle accumulation. var lengthAtTimeFraction = this._lengthAtTimeFraction(timeFraction); + ASSERT_ENABLED && assert(isFinite(lengthAtTimeFraction)); var point = this._path.getPointAtLength(lengthAtTimeFraction); var x = point.x - target.offsetWidth / 2; var y = point.y - target.offsetHeight / 2; @@ -1721,6 +1724,9 @@ PathAnimationEffect.prototype = createObject(AnimationEffect.prototype, { } var scaledFraction = timeFraction * segmentCount; var index = clamp(Math.floor(scaledFraction), 0, segmentCount); + // Special handling for when we reach the end + if (index >= segmentCount) + return this._cumulativeLengths[segmentCount]; return this._cumulativeLengths[index] + ((scaledFraction % 1) * ( this._cumulativeLengths[index + 1] - this._cumulativeLengths[index])); }, From d5a0a9474e9278a568fa5f6d3c86ad91c039e391 Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Wed, 11 Dec 2013 16:52:15 +0900 Subject: [PATCH 2/2] Add some brackets I'm guessing the coding style requires this. --- web-animations.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web-animations.js b/web-animations.js index f3d54889..6f541903 100644 --- a/web-animations.js +++ b/web-animations.js @@ -1694,8 +1694,9 @@ PathAnimationEffect.prototype = createObject(AnimationEffect.prototype, { } }, _sample: function(timeFraction, currentIteration, target) { - if (timeFraction === null) + if (timeFraction === null) { return; + } // TODO: Handle accumulation. var lengthAtTimeFraction = this._lengthAtTimeFraction(timeFraction); ASSERT_ENABLED && assert(isFinite(lengthAtTimeFraction)); @@ -1725,8 +1726,9 @@ PathAnimationEffect.prototype = createObject(AnimationEffect.prototype, { var scaledFraction = timeFraction * segmentCount; var index = clamp(Math.floor(scaledFraction), 0, segmentCount); // Special handling for when we reach the end - if (index >= segmentCount) + if (index >= segmentCount) { return this._cumulativeLengths[segmentCount]; + } return this._cumulativeLengths[index] + ((scaledFraction % 1) * ( this._cumulativeLengths[index + 1] - this._cumulativeLengths[index])); },