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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
<!DOCTYPE html>
<meta charset="UTF-8">
<title>transform-translate composition</title>
<link rel="help" href="https://drafts.csswg.org/css-transforms/#two-d-transform-functions">
<meta name="assert" content="transform-translate supports animation as a transform list">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
<body>
<script src="../interpolation/resources/interpolation-test.js"></script>
<script>
// ------------ Addition tests --------------
test_composition({
property: 'transform',
underlying: 'translate(10px, 20px)',
addFrom: 'translate(100px, 200px)',
addTo: 'translate(200px, 400px)',
}, [
{at: -0.5, expect: 'translate(60px, 120px)'},
{at: 0, expect: 'translate(110px, 220px)'},
{at: 0.25, expect: 'translate(135px, 270px)'},
{at: 0.5, expect: 'translate(160px, 320px)'},
{at: 0.75, expect: 'translate(185px, 370px)'},
{at: 1, expect: 'translate(210px, 420px)'},
{at: 1.5, expect: 'translate(260px, 520px)'},
]);
test_composition({
property: 'transform',
underlying: 'translate(10px, 20px)',
addFrom: 'translate(100px, 200px)',
replaceTo: 'translate(210px, 420px)',
}, [
{at: -0.5, expect: 'translate(60px, 120px)'},
{at: 0, expect: 'translate(110px, 220px)'},
{at: 0.25, expect: 'translate(135px, 270px)'},
{at: 0.5, expect: 'translate(160px, 320px)'},
{at: 0.75, expect: 'translate(185px, 370px)'},
{at: 1, expect: 'translate(210px, 420px)'},
{at: 1.5, expect: 'translate(260px, 520px)'},
]);
// When testing translate functions in isolation, the additive and accumulation
// behaviors are functionally identical. This test includes a rotate to ensure
// both methods are implemented; add should append the from/to after the rotate.
test_composition({
property: 'transform',
underlying: 'translateX(100px) rotate(90deg)',
addFrom: 'translateX(100px)',
addTo: 'translateX(200px)',
}, [
{at: -0.5, expect: 'translateX(100px) rotate(90deg) translateX(50px)'},
{at: 0, expect: 'translateX(100px) rotate(90deg) translateX(100px)'},
{at: 0.25, expect: 'translateX(100px) rotate(90deg) translateX(125px)'},
{at: 0.5, expect: 'translateX(100px) rotate(90deg) translateX(150px)'},
{at: 0.75, expect: 'translateX(100px) rotate(90deg) translateX(175px)'},
{at: 1, expect: 'translateX(100px) rotate(90deg) translateX(200px)'},
{at: 1.5, expect: 'translateX(100px) rotate(90deg) translateX(250px)'},
]);
// ------------ Accumulation tests --------------
test_composition({
property: 'transform',
underlying: 'translateX(100px)',
accumulateFrom: 'translateX(50px)',
accumulateTo: 'translateX(250px)',
}, [
{at: -0.5, expect: 'translateX(50px)'},
{at: 0, expect: 'translateX(150px)'},
{at: 0.25, expect: 'translateX(200px)'},
{at: 0.5, expect: 'translateX(250px)'},
{at: 0.75, expect: 'translateX(300px)'},
{at: 1, expect: 'translateX(350px)'},
{at: 1.5, expect: 'translateX(450px)'},
]);
test_composition({
property: 'transform',
underlying: 'translateY(100px)',
accumulateFrom: 'translateY(50px)',
accumulateTo: 'translateY(250px)',
}, [
{at: -0.5, expect: 'translateY(50px)'},
{at: 0, expect: 'translateY(150px)'},
{at: 0.25, expect: 'translateY(200px)'},
{at: 0.5, expect: 'translateY(250px)'},
{at: 0.75, expect: 'translateY(300px)'},
{at: 1, expect: 'translateY(350px)'},
{at: 1.5, expect: 'translateY(450px)'},
]);
test_composition({
property: 'transform',
underlying: 'translateZ(100px)',
accumulateFrom: 'translateZ(50px)',
accumulateTo: 'translateZ(250px)',
}, [
{at: -0.5, expect: 'translateZ(50px)'},
{at: 0, expect: 'translateZ(150px)'},
{at: 0.25, expect: 'translateZ(200px)'},
{at: 0.5, expect: 'translateZ(250px)'},
{at: 0.75, expect: 'translateZ(300px)'},
{at: 1, expect: 'translateZ(350px)'},
{at: 1.5, expect: 'translateZ(450px)'},
]);
// The translate functions all share the same primitive type (translate3d), so
// can be accumulated between.
test_composition({
property: 'transform',
underlying: 'translate(100px, 50px)',
accumulateFrom: 'translateZ(50px)',
accumulateTo: 'translateZ(250px)',
}, [
{at: -0.5, expect: 'translate3d(100px, 50px, -50px)'},
{at: 0, expect: 'translate3d(100px, 50px, 50px)'},
{at: 0.25, expect: 'translate3d(100px, 50px, 100px)'},
{at: 0.5, expect: 'translate3d(100px, 50px, 150px)'},
{at: 0.75, expect: 'translate3d(100px, 50px, 200px)'},
{at: 1, expect: 'translate3d(100px, 50px, 250px)'},
{at: 1.5, expect: 'translate3d(100px, 50px, 350px)'},
]);
// When testing translate functions in isolation, the additive and accumulation
// behaviors are functionally identical. This test includes a rotate to ensure
// both methods are implemented; accumulate should combine the transform before
// the rotate.
test_composition({
property: 'transform',
underlying: 'translateX(100px) rotate(90deg)',
accumulateFrom: 'translateX(100px)',
accumulateTo: 'translateX(200px)',
}, [
{at: -0.5, expect: 'translateX(150px) rotate(90deg)'},
{at: 0, expect: 'translateX(200px) rotate(90deg)'},
{at: 0.25, expect: 'translateX(225px) rotate(90deg)'},
{at: 0.5, expect: 'translateX(250px) rotate(90deg)'},
{at: 0.75, expect: 'translateX(275px) rotate(90deg)'},
{at: 1, expect: 'translateX(300px) rotate(90deg)'},
{at: 1.5, expect: 'translateX(350px) rotate(90deg)'},
]);
</script>
</body>
|