forked from web-animations/web-animations-js-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_example.html
More file actions
187 lines (153 loc) · 3.95 KB
/
demo_example.html
File metadata and controls
187 lines (153 loc) · 3.95 KB
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
<!--
Copyright 2012 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE html>
<style>
.scene {
position: absolute;
left: 50px;
}
.door {
background-color: gray;
border: 1px solid black;
line-height: 200px;
width: 100px;
}
.doorSpacer {
width: 200px;
-webkit-transform: rotateY(0deg);
-webkit-transform-style: preserve-3d;
}
.doorContainer {
-webkit-transform-style: preserve-3d;
-webkit-perspective: 1000px;
top: 50px;
width: 200px;
height: 200px;
position: absolute;
-webkit-perspective-origin: right center;
}
.right {
left: 450px;
visibility: hidden;
}
.picture {
position: absolute;
left: 150px;
top: 70px;
width: 100px;
height: 75px;
border: solid 1px black;
-webkit-transform: rotate(0deg);
}
.dust {
position: absolute;
left: -25px;
width: 150px;
border-radius: 15px;
height: 30px;
top: 230px;
background-color: #555;
opacity: 0;
}
div#links {
margin: 30px;
}
</style>
<div class="scene">
<div class="doorContainer">
<div class="doorSpacer" id="door">
<div class="door">
o
</div>
</div>
</div>
<div class="dust" id="dust"></div>
<div class="picture" id="picture"></div>
</div>
<svg height="400px">
<circle cx="100px" cy="100px" r="20px"/>
<circle cx="200px" cy="120px" r="15px"/>
<circle cx="130px" cy="315px" r="25px"/>
<circle cx="220px" cy="300px" r="20px"/>
</svg>
<div id="links">
<div>Use the links below to run the steps of the demo.</div>
<a href="#" onclick="first()">first</a>
<a href="#" onclick="second()">second</a>
<a href="#" onclick="third()">third</a>
<a href="#" onclick="fourth()">fourth</a>
<a href="#" onclick="fifth()">fifth</a>
<a href="#" onclick="sixth()">sixth</a>
<a href="#" onclick="seventh()">seventh</a>
<a href="#" onclick="eighth()">eighth</a>
</div>
<script src="web-animation.js"></script>
<script>
// STEP 1
var a = undefined;
function first() {
a = new Animation(document.querySelector(".doorSpacer"),
{ '-webkit-transform': [ 'rotateY(0deg)', 'rotateY(100deg)' ] }, 2);
}
function second() {
new Animation(document.querySelector("circle"), { cx: '400px' }, 3);
}
// STEP 2
function third() {
a.timing.timingFunc = new TimingFunction('ease-in');
a.play();
}
function fourth() {
a.timing.timingFunc = new TimingFunction([0, 0.2,0.8, 1]);
a.play();
}
// STEP 3
var group = undefined;
var pictureTilting = undefined;
function fifth() {
var picture = document.querySelector(".picture");
pictureTilting = new Animation(picture,
{ '-webkit-transform': [ 'rotate(0deg)', 'rotate(-30deg)' ] }, 0.5);
group = new SeqGroup([a, pictureTilting]);
}
function sixth() {
var dust = document.querySelector(".dust");
var dustPuff = new Animation(dust, { opacity: ["0", "0.4", "0"] }, 0.3);
group.add(new ParGroup([ pictureTilting, dustPuff ]));
group.play();
}
// STEP 4
function audioAnimFunction() {
return {
sample: function(timeFraction, currentIteration, target) {
// TODO: fix this
console.log(timeFraction);
}
};
}
function seventh() {
var doorCreakAnim =
new Animation(null, new audioAnimFunction("CREEEEEEAAAAKKK"), 2);
var closeAnim = new ParGroup([ a, doorCreakAnim ]);
closeAnim.timing.timingFunc = a.timing.timingFunc;
a.timing.timingFunc = null;
group.splice(0, 0, closeAnim);
group.play();
}
// STEP 5
function eighth() {
group.timing.playbackRate = 2;
group.play();
}
</script>
<script src="web-animation-visualization.js"></script>