Skip to content

Commit

Permalink
Merge pull request #476 from suzyh/effect-easing-break-loop
Browse files Browse the repository at this point in the history
Prevent cubic bezier from infinite-looping
  • Loading branch information
alancutter authored Jul 26, 2016
2 parents 853d61c + 2d50f47 commit c83039c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/timing-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@
return x;
}
var start = 0, end = 1;
while (1) {
while (start < end) {
var mid = (start + end) / 2;
function f(a, b, m) { return 3 * a * (1 - m) * (1 - m) * m + 3 * b * (1 - m) * m * m + m * m * m};
var xEst = f(a, c, mid);
if (Math.abs(x - xEst) < 0.0001) {
if (Math.abs(x - xEst) < 0.00001) {
return f(b, d, mid);
}
if (xEst < x) {
Expand All @@ -191,6 +191,7 @@
end = mid;
}
}
return f(b, d, mid);
}
}

Expand Down
23 changes: 20 additions & 3 deletions test/web-platform-tests-expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ module.exports = {
'test/web-platform-tests/web-animations/interfaces/Animation/constructor.html':
'KeyframeEffectReadOnly is not defined causing the test to timeout.',

'test/web-platform-tests/web-animations/interfaces/KeyframeEffect/effect-easing.html':
'It seems to enter an infinite loop and halt the browser.',

'test/web-platform-tests/web-animations/interfaces/KeyframeEffect/effect-easing-steps.html':
'It seems to enter an infinite loop and halt the browser.',
},
Expand Down Expand Up @@ -860,6 +857,26 @@ module.exports = {
'KeyframeEffectReadOnly is not defined',
},

'test/web-platform-tests/web-animations/interfaces/KeyframeEffect/effect-easing.html': {
'effect easing produces values greater than 1 with keyframe easing cubic-bezier(0, 0, 0, 0)':
'assert_approx_equals: The left of the animation should be approximately 102.40666638411385 at 250ms expected 102.40666638411385 +/- 0.01 but got 100',

'effect easing produces values greater than 1 with keyframe easing cubic-bezier(1, 1, 1, 1)':
'assert_approx_equals: The left of the animation should be approximately 102.40666638411385 at 250ms expected 102.40666638411385 +/- 0.01 but got 100',

'effect easing produces negative values 1 with keyframe easing cubic-bezier(0, 0, 0, 0)':
'assert_approx_equals: The left of the animation should be approximately -29.501119758965654 at 250ms expected -29.501119758965654 +/- 0.01 but got 0',

'effect easing produces negative values 1 with keyframe easing cubic-bezier(1, 1, 1, 1)':
'assert_approx_equals: The left of the animation should be approximately -29.501119758965654 at 250ms expected -29.501119758965654 +/- 0.01 but got 0',

'effect easing produces values greater than 1 with keyframe easing producing values greater than 1':
'assert_approx_equals: The left of the animation should be approximately 101.9006796334848 at 240ms expected 101.9006796334848 +/- 0.01 but got 100',

'effect easing produces negative values with keyframe easing producing negative values':
'assert_approx_equals: The left of the animation should be approximately -16.589193103032184 at 10ms expected -16.589193103032184 +/- 0.01 but got 0',
},

'test/web-platform-tests/web-animations/interfaces/KeyframeEffect/getComputedTiming.html': {
'getComputedTiming().activeDuration for a non-zero duration and default iteration count':
'KeyframeEffectReadOnly is not defined',
Expand Down

0 comments on commit c83039c

Please sign in to comment.