-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathcalc-interpolation.html
129 lines (119 loc) · 3.34 KB
/
calc-interpolation.html
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
<!DOCTYPE html>
<meta charset="UTF-8">
<title>calc interpolation</title>
<link rel="help" href="https://drafts.csswg.org/css-values-3/#calc-notation">
<meta name="assert" content="calc supports animation by computed value">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
<style>
.container {
position: relative;
width: 50px;
height: 50px;
border: black solid 2px;
display: inline-block;
margin-left: 10px;
margin-right: 10px;
background-color: white;
}
.target {
position: absolute;
width: 10px;
height: 50px;
background-color: black;
}
.expected {
background-color: green;
}
</style>
<body>
<template id="target-template">
<div class="container">
<div class="target"></div>
</div>
</template>
<script>
const APPROX_INFINITY = 3.35544e+07;
test_interpolation({
property: 'left',
from: '0px',
to: 'calc(infinity * 1px)',
target_names:['CSS Transitions', 'CSS Transitions with transition: all']
}, [
{at: -0.25, expect: `${APPROX_INFINITY * -0.25 }px`},
{at: 0, expect: '0px'},
{at: 0.25, expect: `${APPROX_INFINITY * 0.25}px`},
{at: 0.5, expect: `${APPROX_INFINITY * 0.5}px`},
{at: 0.75, expect: `${APPROX_INFINITY * 0.75}px`},
{at: 1, expect: `${APPROX_INFINITY}px`},
{at: 1.25, expect: `${APPROX_INFINITY * 1.25}px`}
]);
test_interpolation({
property: 'left',
from: '0px',
to: 'calc(infinity * 1px)',
target_names:['CSS Animations', 'Web Animations']
}, [
{at: -0.25, expect: `${-APPROX_INFINITY}px`},
{at: 0, expect: `${APPROX_INFINITY}px`},
{at: 0.25, expect: `${APPROX_INFINITY}px`},
{at: 0.5, expect: `${APPROX_INFINITY}px`},
{at: 0.75, expect: `${APPROX_INFINITY}px`},
{at: 1, expect: `${APPROX_INFINITY}px`},
{at: 1.25, expect: `${APPROX_INFINITY}px`}
]);
test_interpolation({
property: 'left',
from: 'calc(50% - 25px)',
to: 'calc(100% - 10px)'
}, [
{at: -0.25, expect: '-10px'},
{at: 0, expect: '0px'},
{at: 0.25, expect: '10px'},
{at: 0.5, expect: '20px'},
{at: 0.75, expect: '30px'},
{at: 1, expect: '40px'},
{at: 1.25, expect: '50px'}
]);
test_interpolation({
property: 'text-indent',
from: 'calc(50% - 25px)',
to: 'calc(100% - 10px)'
}, [
{at: -0.25, expect: 'calc(((50% - 25px) * 1.25) + ((100% - 10px) * -0.25))'},
{at: 0, expect: 'calc(50% - 25px)'},
{at: 0.25, expect: 'calc(((50% - 25px) * 0.75) + ((100% - 10px) * 0.25))'},
{at: 0.5, expect: 'calc(((50% - 25px) * 0.5) + ((100% - 10px) * 0.5))'},
{at: 0.75, expect: 'calc(((50% - 25px) * 0.25) + ((100% - 10px) * 0.75))'},
{at: 1, expect: 'calc(100% - 10px)'},
{at: 1.25, expect: 'calc(((50% - 25px) * -0.25) + ((100% - 10px) * 1.25))'}
]);
test_interpolation({
property: 'text-indent',
from: '0em',
to: '100px'
}, [
{at: -0.25, expect: '-25px'},
{at: 0, expect: '0em'},
{at: 0.25, expect: '25px'},
{at: 0.5, expect: '50px'},
{at: 0.75, expect: '75px'},
{at: 1, expect: '100px'},
{at: 1.25, expect: '125px'}
]);
test_interpolation({
property: 'text-indent',
from: '0%',
to: '100px'
}, [
{at: -0.25, expect: 'calc(0% + -25px)'},
{at: 0, expect: '0%'},
{at: 0.25, expect: 'calc(0% + 25px)'},
{at: 0.5, expect: 'calc(0% + 50px)'},
{at: 0.75, expect: 'calc(0% + 75px)'},
{at: 1, expect: 'calc(0% + 100px)'},
{at: 1.25, expect: 'calc(0% + 125px)'}
]);
</script>
</body>