summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-backgrounds/animations/background-position-origin-interpolation.html
blob: f34145c5736956d3dbac0192f3e7ec7ac053e04a (plain)
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<!doctype html>
<meta charset="utf-8">
<link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#background-position">
<meta name="test" content="background-position animation handles origin parameters">

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>

<style>
.parent {
  background-position: 80px 80px;
}
.target {
  border: 3px solid skyblue;
  width: 100px;
  height: 100px;
  background-image: linear-gradient(to right, green, green);
  background-size: 20px 20px;
  background-repeat: no-repeat;
  background-position: 10px 10px;
  display: inline-block;
}

.actual {
  background-image: linear-gradient(to right, red, red);
}
.expected {
  margin-left: -106px;
}
</style>

<body></body>

<script>
// neutral
test_interpolation({
  property: 'background-position',
  from: neutralKeyframe,
  to: 'left 20px top 20px',
}, [
  {at: 0, expect: '10px 10px'},
  {at: 0.25, expect: '12.5px 12.5px'},
  {at: 0.5, expect: '15px 15px'},
  {at: 0.75, expect: '17.5px 17.5px'},
  {at: 1, expect: '20px 20px'},
]);

// initial
test_interpolation({
  property: 'background-position',
  from: 'initial',
  to: 'left 20px top 20px',
}, [
  {at: 0, expect: '0% 0%'},
  {at: 0.25, expect: 'calc(0% + 5px) calc(0% + 5px)'},
  {at: 0.5, expect: 'calc(0% + 10px) calc(0% + 10px)'},
  {at: 0.75, expect: 'calc(0% + 15px) calc(0% + 15px)'},
  {at: 1, expect: 'calc(0% + 20px) calc(0% + 20px)'},
]);

// inherit
test_interpolation({
  property: 'background-position',
  from: 'inherit',
  to: 'left 20px top 20px',
}, [
  {at: 0, expect: '80px 80px'},
  {at: 0.25, expect: '65px 65px'},
  {at: 0.5, expect: '50px 50px'},
  {at: 0.75, expect: '35px 35px'},
  {at: 1, expect: '20px 20px'},
]);

// unset
test_interpolation({
  property: 'background-position',
  from: 'unset',
  to: 'left 20px top 20px',
}, [
  {at: 0, expect: '0% 0%'},
  {at: 0.25, expect: 'calc(0% + 5px) calc(0% + 5px)'},
  {at: 0.5, expect: 'calc(0% + 10px) calc(0% + 10px)'},
  {at: 0.75, expect: 'calc(0% + 15px) calc(0% + 15px)'},
  {at: 1, expect: 'calc(0% + 20px) calc(0% + 20px)'},
]);

// left-top
test_interpolation({
  property: 'background-position',
  from: 'center center',
  to: 'left 20px top 20px',
}, [
  {at: 0, expect: '50% 50%'},
  {at: 0.25, expect: 'calc(5px + 37.5%) calc(5px + 37.5%)'},
  {at: 0.5, expect: 'calc(10px + 25%) calc(10px + 25%)'},
  {at: 0.75, expect: 'calc(15px + 12.5%) calc(15px + 12.5%)'},
  {at: 1, expect: 'calc(0% + 20px) calc(0% + 20px)'},
]);

// center-top
test_interpolation({
  property: 'background-position',
  from: 'center center',
  to: 'center top 20px',
}, [
  {at: 0, expect: '50% 50%'},
  {at: 0.25, expect: '50% calc(5px + 37.5%)'},
  {at: 0.5, expect: '50% calc(10px + 25%)'},
  {at: 0.75, expect: '50% calc(15px + 12.5%)'},
  {at: 1, expect: '50% calc(0% + 20px)'},
]);

// right-top
test_interpolation({
  property: 'background-position',
  from: 'center center',
  to: 'right 20px top 20px',
}, [
  {at: 0, expect: '50% 50%'},
  {at: 0.25, expect: 'calc(-5px + 62.5%) calc(5px + 37.5%)'},
  {at: 0.5, expect: 'calc(-10px + 75%) calc(10px + 25%)'},
  {at: 0.75, expect: 'calc(-15px + 87.5%) calc(15px + 12.5%)'},
  {at: 1, expect: 'calc(-20px + 100%) calc(0% + 20px)'},
]);

// left-center
test_interpolation({
  property: 'background-position',
  from: 'center center',
  to: 'left 20px center',
}, [
  {at: 0, expect: '50% 50%'},
  {at: 0.25, expect: 'calc(5px + 37.5%) 50%'},
  {at: 0.5, expect: 'calc(10px + 25%) 50%'},
  {at: 0.75, expect: 'calc(15px + 12.5%) 50%'},
  {at: 1, expect: 'calc(0% + 20px) 50%'},
]);

// center-center
test_interpolation({
  property: 'background-position',
  from: 'center center',
  to: 'center center',
}, [
  {at: 0, expect: '50% 50%'},
  {at: 0.25, expect: '50% 50%'},
  {at: 0.5, expect: '50% 50%'},
  {at: 0.75, expect: '50% 50%'},
  {at: 1, expect: '50% 50%'},
]);

// right-center
test_interpolation({
  property: 'background-position',
  from: 'center center',
  to: 'right 20px center',
}, [
  {at: 0, expect: '50% 50%'},
  {at: 0.25, expect: 'calc(-5px + 62.5%) 50%'},
  {at: 0.5, expect: 'calc(-10px + 75%) 50%'},
  {at: 0.75, expect: 'calc(-15px + 87.5%) 50%'},
  {at: 1, expect: 'calc(-20px + 100%) 50%'},
]);

// left-bottom
test_interpolation({
  property: 'background-position',
  from: 'center center',
  to: 'left 20px bottom 20px',
}, [
  {at: 0, expect: '50% 50%'},
  {at: 0.25, expect: 'calc(5px + 37.5%) calc(-5px + 62.5%)'},
  {at: 0.5, expect: 'calc(10px + 25%) calc(-10px + 75%)'},
  {at: 0.75, expect: 'calc(15px + 12.5%) calc(-15px + 87.5%)'},
  {at: 1, expect: 'calc(0% + 20px) calc(-20px + 100%)'},
]);

// center-bottom
test_interpolation({
  property: 'background-position',
  from: 'center center',
  to: 'center bottom 20px',
}, [
  {at: 0, expect: '50% 50%'},
  {at: 0.25, expect: '50% calc(-5px + 62.5%)'},
  {at: 0.5, expect: '50% calc(-10px + 75%)'},
  {at: 0.75, expect: '50% calc(-15px + 87.5%)'},
  {at: 1, expect: '50% calc(-20px + 100%)'},
]);

// right-bottom
test_interpolation({
  property: 'background-position',
  from: 'center center',
  to: 'right 20px bottom 20px',
}, [
  {at: 0, expect: '50% 50%'},
  {at: 0.25, expect: 'calc(-5px + 62.5%) calc(-5px + 62.5%)'},
  {at: 0.5, expect: 'calc(-10px + 75%) calc(-10px + 75%)'},
  {at: 0.75, expect: 'calc(-15px + 87.5%) calc(-15px + 87.5%)'},
  {at: 1, expect: 'calc(-20px + 100%) calc(-20px + 100%)'},
]);

// Single values
test_interpolation({
  property: 'background-position',
  from: 'center',
  to: 'bottom',
}, [
  {at: 0, expect: '50% 50%'},
  {at: 0.25, expect: '50% 62.5%'},
  {at: 0.5, expect: '50% 75%'},
  {at: 0.75, expect: '50% 87.5%'},
  {at: 1, expect: '50% 100%'},
]);
</script>