| <!doctype html> |
| <html> |
| <head> |
| <title>Test simple fill mode on transform</title> |
| <style> |
| .box { |
| position: relative; |
| left: 10px; |
| top: 10px; |
| height: 100px; |
| width: 100px; |
| -webkit-transform: translate3d(100px, 0, 0); |
| -webkit-animation-delay: 0.1s; |
| -webkit-animation-duration: 0.1s; |
| -webkit-animation-timing-function: linear; |
| -webkit-animation-name: anim; |
| } |
| @-webkit-keyframes anim { |
| from { -webkit-transform: translate3d(200px, 0, 0); } |
| to { -webkit-transform: translate3d(300px, 0, 0); } |
| } |
| #a { |
| background-color: #f99; |
| -webkit-animation-fill-mode: both; |
| -webkit-animation-iteration-count: 2; |
| -webkit-animation-direction: reverse; |
| } |
| #b { |
| background-color: #999; |
| -webkit-animation-fill-mode: both; |
| -webkit-animation-iteration-count: 2; |
| -webkit-animation-direction: alternate-reverse; |
| } |
| </style> |
| <script src="resources/animation-test-helpers.js"></script> |
| <script> |
| const numAnims = 1; |
| var animsFinished = 0; |
| const allowance = 5; |
| const expectedValues = [ |
| {id: "a", start: 300, end: 200}, |
| {id: "b", start: 300, end: 300} |
| ]; |
| var result = ""; |
| |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| function animationEnded(event) { |
| if (++animsFinished == numAnims) { |
| setTimeout(endTest, 0); // This call to setTimeout should be ok in the test environment |
| // since we're just giving style a chance to resolve. |
| } |
| }; |
| |
| function endTest() { |
| |
| for (var i = 0; i < expectedValues.length; i++) { |
| var realValue = getPropertyValue("webkitTransform.4", expectedValues[i].id); |
| var expectedValue = expectedValues[i].end; |
| if (comparePropertyValue("webkitTransform.4", realValue, expectedValue, allowance)) |
| result += "PASS"; |
| else |
| result += "FAIL"; |
| result += " - end of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>"; |
| } |
| document.getElementById('result').innerHTML = result; |
| |
| if (window.testRunner) |
| testRunner.notifyDone(); |
| } |
| |
| window.onload = function () { |
| for (var i = 0; i < expectedValues.length; i++) { |
| var realValue = getPropertyValue("webkitTransform.4", expectedValues[i].id); |
| var expectedValue = expectedValues[i].start; |
| if (comparePropertyValue("webkitTransform.4", realValue, expectedValue, allowance)) |
| result += "PASS"; |
| else |
| result += "FAIL"; |
| result += " - start of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>"; |
| } |
| document.addEventListener("webkitAnimationEnd", animationEnded, false); |
| }; |
| |
| </script> |
| </head> |
| <body> |
| This test performs an animation of the transform property with different |
| fill modes. It animates over 0.1 second with a 0.1 second delay. |
| It takes snapshots at document load and the end of the animations. |
| <div id="a" class="box"> |
| Both Iterate - Reverse |
| </div> |
| <div id="b" class="box"> |
| Both Iterate - Alternate Reverse |
| </div> |
| <div id="result"> |
| </div> |
| </body> |
| </html> |