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 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>rotate interpolation</title>
<link rel="help" href="https://drafts.csswg.org/css-transforms-2/#propdef-rotate">
<meta name="assert" content="rotate supports animation.">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
</head>
<style>
.parent {
rotate: 90deg;
}
.target {
width: 40px;
height: 20px;
background-color: grey;
rotate: 10deg;
}
.expected {
background-color: green;
}
</style>
<template id="target-template">
<div class="parent">
<div class="target">Text</div>
</div>
</template>
<body>
<script>
test_interpolation({
property: 'rotate',
from: '100deg',
to: '180deg',
}, [
{at: -1, expect: '20deg'},
{at: 0, expect: '100deg'},
{at: 0.125, expect: '110deg'},
{at: 0.875, expect: '170deg'},
{at: 1, expect: '180deg'},
{at: 2, expect: '260deg'}
]);
test_interpolation({
property: 'rotate',
from: '45deg',
to: '-1 1 0 60deg',
}, [
{at: -1, expect: '0.447214 -0.447214 0.774597 104.478deg'},
{at: 0, expect: '45deg'},
{at: 0.125, expect: '-0.136456 0.136456 0.981203 40.6037deg'},
{at: 0.875, expect: '-0.70246 0.70246 0.114452 53.1994deg'},
{at: 1, expect: '-0.71 0.71 0 60deg'},
{at: 2, expect: '-0.637897 0.637897 -0.431479 124.975deg'}
]);
test_interpolation({
property: 'rotate',
from: 'none',
to: '7 -8 9 400grad',
}, [
{at: -1, expect: '0.5 -0.57 0.65 -400grad'},
{at: 0, expect: '0.5 -0.57 0.65 0deg'},
{at: 0.125, expect: '0.5 -0.57 0.65 50grad'},
{at: 0.875, expect: '0.5 -0.57 0.65 350grad'},
{at: 1, expect: '0.5 -0.57 0.65 400grad'},
{at: 2, expect: '0.5 -0.57 0.65 800grad'}
]);
test_interpolation({
property: 'rotate',
from: 'none',
to: 'none',
}, [
{at: -1, expect: 'none'},
{at: 0, expect: 'none'},
{at: 0.125, expect: 'none'},
{at: 0.875, expect: 'none'},
{at: 1, expect: 'none'},
{at: 2, expect: 'none'}
]);
test_interpolation({
property: 'rotate',
from: 'none',
to: '30deg',
}, [
{at: -1, expect: '-30deg'},
{at: 0, expect: '0deg'},
{at: 0.25, expect: '7.5deg'},
{at: 0.75, expect: '22.5deg'},
{at: 1, expect: '30deg'},
{at: 2, expect: '60deg'},
]);
test_interpolation({
property: 'rotate',
from: neutralKeyframe,
to: '30deg',
}, [
{at: -1, expect: '-10deg'},
{at: 0, expect: '10deg'},
{at: 0.25, expect: '15deg'},
{at: 0.75, expect: '25deg'},
{at: 1, expect: '30deg'},
{at: 2, expect: '50deg'},
]);
test_interpolation({
property: 'rotate',
from: 'inherit',
to: '270deg',
}, [
{at: -1, expect: '-90deg'},
{at: 0, expect: '90deg'},
{at: 0.25, expect: '135deg'},
{at: 0.75, expect: '225deg'},
{at: 1, expect: '270deg'},
{at: 2, expect: '450deg'},
]);
test_interpolation({
property: 'rotate',
from: 'unset',
to: '30deg',
}, [
{at: -1, expect: '-30deg'},
{at: 0, expect: '0deg'},
{at: 0.25, expect: '7.5deg'},
{at: 0.75, expect: '22.5deg'},
{at: 1, expect: '30deg'},
{at: 2, expect: '60deg'},
]);
test_interpolation({
property: 'rotate',
from: '100deg',
to: '-100deg',
}, [
{at: -1, expect: '300deg'},
{at: 0, expect: '100deg'},
{at: 0.25, expect: '50deg'},
{at: 0.75, expect: '-50deg'},
{at: 1, expect: '-100deg'},
{at: 2, expect: '-300deg'},
]);
test_interpolation({
property: 'rotate',
from: '0 1 0 100deg',
to: '0 1 0 -100deg',
}, [
{at: -1, expect: '0 1 0 300deg'},
{at: 0, expect: '0 1 0 100deg'},
{at: 0.25, expect: '0 1 0 50deg'},
{at: 0.75, expect: '0 1 0 -50deg'},
{at: 1, expect: '0 1 0 -100deg'},
{at: 2, expect: '0 1 0 -300deg'},
]);
test_interpolation({
property: 'rotate',
from: '1 -2.5 3.64 100deg',
to: '1 -2.5 3.64 -100deg',
}, [
{at: -1, expect: '0.22 -0.55 0.8 300deg'},
{at: 0, expect: '0.22 -0.55 0.8 100deg'},
{at: 0.25, expect: '0.22 -0.55 0.8 50deg'},
{at: 0.75, expect: '0.22 -0.55 0.8 -50deg'},
{at: 1, expect: '0.22 -0.55 0.8 -100deg'},
{at: 2, expect: '0.22 -0.55 0.8 -300deg'},
]);
// The rotation angle gets interpolated numerically and the rotation vector
// of the non-zero angle is used or (0, 0, 1) if both angles are zero.
// So, we have to convert "1 0 0 0deg" into "0 1 0 0deg", and apply the same
// concept for other test cases.
// https://drafts.csswg.org/css-transforms-2/#interpolation-of-transform-functions
test_interpolation({
property: 'rotate',
from: '1 0 0 0deg',
to: '0 1 0 10deg',
}, [
{at: -1, expect: '0 1 0 -10deg'},
{at: 0, expect: '0 1 0 0deg'},
{at: 0.25, expect: '0 1 0 2.5deg'},
{at: 0.75, expect: '0 1 0 7.5deg'},
{at: 1, expect: '0 1 0 10deg'},
{at: 2, expect: '0 1 0 20deg'},
]);
test_interpolation({
property: 'rotate',
from: '1 1 0 90deg',
to: '0 1 1 135deg',
}, [
{at: -1, expect: '0.67 -0.06 -0.74 124.97deg'},
{at: 0, expect: '0.71 0.71 0 90deg'},
{at: 0.25, expect: '0.54 0.8 0.26 94.83deg'},
{at: 0.75, expect: '0.17 0.78 0.61 118.68deg'},
{at: 1, expect: '0 0.71 0.71 135deg'},
// The result in Blink is '0.52 -0.29 -0.81 151.04deg', and the result in
// Gecko is `-0.52 0.29 0.8 208.96deg`. Both of them can be represented as the
// same 3d rotation (but by an opposite direction vector and angle).
// The spec only mentions we should use Slerp to do interpolation for rotate
// property, but it seems the implementation detail for extrapolation are
// different (because this is not in the range of [0, 1]).
// For now, we make both results pass because their rendering results are the
// same.
{at: 2, expect: '0.52 -0.29 -0.81 151.04deg',
option: '-0.52 0.29 0.81 208.96deg'},
]);
test_interpolation({
property: 'rotate',
from: '0 1 0 0deg',
to: '1 0 0 450deg',
}, [
{at: -1, expect: '1 0 0 -450deg'},
{at: 0, expect: '1 0 0 0deg'},
{at: 0.25, expect: '1 0 0 112.5deg'},
{at: 0.75, expect: '1 0 0 337.5deg'},
{at: 1, expect: '1 0 0 450deg'},
{at: 2, expect: '1 0 0 900deg'},
]);
test_interpolation({
property: 'rotate',
from: '1 0 0 450deg',
to: '0 1 0 0deg',
}, [
{at: -1, expect: '1 0 0 900deg'},
{at: 0, expect: '1 0 0 450deg'},
{at: 0.25, expect: '1 0 0 337.5deg'},
{at: 0.75, expect: '1 0 0 112.5deg'},
{at: 1, expect: '1 0 0 0deg'},
{at: 2, expect: '1 0 0 -450deg'},
]);
</script>
</body>
</html>
|