Skip to content

Commit b73aa7a

Browse files
committed
[css-transforms-2] Copy the rest of the section "Interpolation of primitives and derived transform functions" from css-transforms-1.
1 parent fafb8b9 commit b73aa7a

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

css-transforms-2/Overview.bs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,55 @@ The transform functions <<matrix()>>, ''matrix3d()'' and ''perspective()'' get c
12671267

12681268
For interpolations with the primitive ''rotate3d()'', the direction vectors of the transform functions get normalized first. If the normalized vectors are not equal and both rotation angles are non-zero the transform functions get converted into 4x4 matrices first and interpolated as defined in section <a href="#matrix-interpolation">Interpolation of Matrices</a> afterwards. Otherwise 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.
12691269

1270+
<div class="example">
1271+
1272+
The two transform functions ''translate(0)'' and ''translate(100px)'' are of the same type, have the same number of arguments and therefore can get interpolated numerically. ''translateX(100px)'' is not of the same type and ''translate(100px, 0)'' does not have the same number of arguments, therefore these transform functions can not get interpolated without a former conversion step.
1273+
1274+
</div>
1275+
1276+
Two different types of transform functions that share the same primitive, or transform functions of the same type with different number of arguments can be interpolated. Both transform functions need a former conversion to the common primitive first and get interpolated numerically afterwards. The computed value will be the primitive with the resulting interpolated arguments.
1277+
1278+
<div class="example">
1279+
1280+
The following example describes a transition from ''translateX(100px)'' to ''translateY(100px)'' in 3 seconds on hovering over the div box. Both transform functions derive from the same primitive ''translate()''
1281+
and therefore can be interpolated.
1282+
1283+
<pre><code highlight=css>
1284+
div {
1285+
transform: translateX(100px);
1286+
}
1287+
1288+
div:hover {
1289+
transform: translateY(100px);
1290+
transition: transform 3s;
1291+
}
1292+
</code></pre>
1293+
1294+
For the time of the transition both transform functions get transformed to the common primitive. ''translateX(100px)'' gets converted to ''translate(100px, 0)'' and ''translateY(100px)'' gets converted to ''translate(0, 100px)''. Both transform functions can then get interpolated numerically.
1295+
</div>
1296+
1297+
If both transform functions share a primitive in the two-dimensional space, both transform functions get converted to the two-dimensional primitive. If one or both transform functions are three-dimensional transform functions, the common three-dimensional primitive is used.
1298+
1299+
<div class="example">
1300+
1301+
In this example a two-dimensional transform function gets animated to a three-dimensional transform function. The common primitive is ''translate3d()''.
1302+
1303+
<pre><code highlight=css>
1304+
div {
1305+
transform: translateX(100px);
1306+
}
1307+
1308+
div:hover {
1309+
transform: translateZ(100px);
1310+
transition: transform 3s;
1311+
}
1312+
</code></pre>
1313+
1314+
First ''translateX(100px)'' gets converted to ''translate3d(100px, 0, 0)'' and ''translateZ(100px)'' to ''translate3d(0, 0, 100px)'' respectively. Then both converted transform functions get interpolated numerically.
1315+
1316+
</div>
1317+
1318+
12701319
Addition and accumulation of transform lists {#combining-transform-lists}
12711320
============================================
12721321

0 commit comments

Comments
 (0)