Skip to content

Commit 5457417

Browse files
adding web animations api version
1 parent 4d175e2 commit 5457417

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This repository contains examples of CSS usage.
44

5-
The "animation-frames-timing-function" directory contains a simple example that demonstrates the difference between the step() timing function available for CSS animations and transitions, and the new frames() timing function. [Run the example live](http://mdn.github.io/css-examples/animation-frames-timing-function/). You can also find a version that shows the [same timing function used with transitions](http://mdn.github.io/css-examples/animation-frames-timing-function/index-transitions.html).
5+
The "animation-frames-timing-function" directory contains a simple example that demonstrates the difference between the steps() timing function available for CSS animations and transitions, and the new frames() timing function. [Run the example live](http://mdn.github.io/css-examples/animation-frames-timing-function/). You can also find versions that show the same timing function [used with transitions](http://mdn.github.io/css-examples/animation-frames-timing-function/index-transitions.html), and used with the [Web Animations API](http://mdn.github.io/css-examples/animation-frames-timing-function/index-waa.html).
66

77
The "counter-style-demo" directory contains a demo for the [@counter-style documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/@counter-style). See the live demo [here](https://mdn.github.io/css-examples/counter-style-demo/).
88

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Web animations API frames example</title>
6+
<style>
7+
body {
8+
margin: 0;
9+
}
10+
11+
div {
12+
position: relative;
13+
width: 0%;
14+
height: 200px;
15+
background: red;
16+
}
17+
18+
p {
19+
position: absolute;
20+
width: 250px;
21+
top: 10px;
22+
left: 10px;
23+
color: white;
24+
}
25+
26+
</style>
27+
</head>
28+
<body>
29+
<div class="div1"><p>transition-timing-function: frames(10)<p></div>
30+
<div class="div2"><p>transition-timing-function: steps(10);<p></div>
31+
<div class="div3"><p>transition-timing-function: ease-in;<p></div>
32+
33+
<script>
34+
35+
var easingFunctions = [
36+
'frames(10)',
37+
'steps(10)',
38+
'ease-in'
39+
]
40+
41+
var keyFrames = [
42+
{ width: '0%', background : 'red'},
43+
{ width: '100%', background : 'blue'},
44+
]
45+
46+
var divs = document.querySelectorAll('div');
47+
48+
for(var i = 0; i < divs.length; i++) {
49+
divs[i].animate(keyFrames, {
50+
easing : easingFunctions[i],
51+
duration : 5000,
52+
iterations: Infinity
53+
});
54+
}
55+
56+
</script>
57+
</body>
58+
</html>

0 commit comments

Comments
 (0)