1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
5 <meta http-equiv=
"Content-type" content=
"text/html; charset=utf-8">
6 <title>-webkit-transform-origin vs. Transform Functions
</title>
7 <style type=
"text/css" media=
"screen">
12 -webkit-perspective:
800;
22 background-color: #
282;
23 -webkit-animation-duration:
2s;
24 -webkit-animation-iteration-count: infinite;
25 -webkit-animation-timing-function: linear;
26 -webkit-transform-origin: center center
200px;
28 @-webkit-keyframes b1 {
29 from { transform: rotateY(
0deg); }
30 5% { transform: rotateY(
90deg); }
31 20% { transform: rotateY(
90deg); }
32 50% { transform: rotateY(
180deg); }
33 75% { transform: rotateY(
270deg); }
34 to { transform: rotateY(
360deg); }
42 background-color: #
282;
43 -webkit-animation-duration:
2s;
44 -webkit-animation-iteration-count: infinite;
45 -webkit-animation-timing-function: linear;
47 @-webkit-keyframes b2 {
48 from { transform: translateZ(
200px) rotateY(
0deg) translateZ(-
200px) }
49 5% { transform: translateZ(
200px) rotateY(
90deg) translateZ(-
200px) }
50 20% { transform: translateZ(
200px) rotateY(
90deg) translateZ(-
200px) }
51 50% { transform: translateZ(
200px) rotateY(
180deg) translateZ(-
200px) }
52 75% { transform: translateZ(
200px) rotateY(
270deg) translateZ(-
200px) }
53 to { transform: translateZ(
200px) rotateY(
360deg) translateZ(-
200px) }
57 <script type=
"text/javascript" charset=
"utf-8">
58 if (window.testRunner) {
59 testRunner.dumpAsText();
60 testRunner.waitUntilDone();
66 "b1" : [
0,
0,-
1,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1 ],
67 "b2" : [
0,
0,-
1,
0,
0,
1,
0,
0,
1,
0,
0,
0, -
200,
0,
200,
1 ]
70 const tolerance =
0.2;
71 function isEqual(actual, desired)
73 var diff = Math.abs(actual - desired);
74 return diff <= tolerance;
81 var e = document.getElementById(id);
82 var t = window.getComputedStyle(e).webkitTransform;
84 var array = a[
1].split(
",");
86 for (i =
0; i <
16; ++i) {
87 var actual = parseFloat(array[i]);
88 var expect = expected[id][i];
89 if (!isEqual(actual, expect)) {
90 resultEntries.push(
"FAIL(element '"+id+
"' matrix["+i+
"]' was:"+actual+
", expected:"+expect+
")<br>");
96 resultEntries.push(
"PASS(element '"+id+
"' matches expected value)<br>");
99 if (numSnapshots ==
2) {
100 resultEntries.sort();
101 document.getElementById('result').innerHTML = resultEntries.join(
"");
102 if (window.testRunner)
103 testRunner.notifyDone();
107 function snapshotOnTimeout(id) {
108 setTimeout(
"snapshot('" + id +
"')",
250);
111 function startAnimation(id)
113 var element = document.getElementById(id);
114 element.addEventListener('webkitAnimationStart', function() {
115 // delay to give hardware animations a chance to start
116 window.setTimeout(
"snapshotOnTimeout('" + id +
"')",
0);
118 element.style.webkitAnimationName = id;
123 startAnimation('b1');
124 startAnimation('b2');
129 <body onload=
"start()">
132 <div style=
"transform:translateZ(-200px); transform-style:preserve-3d;">
137 <div id=
"result"> </div>