1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
<!doctype html>
<html>
<head>
<title>Test simple fill mode on transform</title>
<style>
.box {
position: relative;
left: 10px;
top: 10px;
height: 100px;
width: 100px;
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 { transform: translate3d(200px, 0, 0); }
to { 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();
testRunner.waitUntilDone();
}
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>
|