-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathoffsetAnchorPosition.html
More file actions
88 lines (77 loc) · 1.93 KB
/
offsetAnchorPosition.html
File metadata and controls
88 lines (77 loc) · 1.93 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
<!DOCTYPE html>
<script src="../third_party/web-animations-js/web-animations.dev.js"></script>
<script src="../motion-path-polyfill.min.js"></script>
<div id="container">
<div id="targetA">
</div>
<div id="targetB">
</div>
<div id="targetC">
</div>
<div id="targetD">
</div>
</div>
<style>
body {
margin: 0px;
background-color: black;
}
#container {
position: absolute;
left: 300px;
top: 300px;
background-color: white;
width: 500px;
height: 500px;
transform: scale(1);
}
#targetA {
width: 100px;
height: 100px;
background-color: lime;
position: absolute;
left: 300px;
top: 300px;
}
#targetB {
width: 160px;
height: 100px;
background-color: yellow;
position: absolute;
left: 300px;
top: 300px;
}
#targetC {
width: 160px;
height: 160px;
background-color: blue;
position: absolute;
left: 300px;
top: 300px;
}
#targetD {
width: 100px;
height: 160px;
background-color: red;
position: absolute;
left: 300px;
top: 300px;
}
</style>
<script>
var keyframes = [
{offsetPosition: '0% 0%', offsetAnchor: 'auto'},
{offsetPosition: '100% 0%', offsetAnchor: 'auto'},
{offsetPosition: '100% 100%', offsetAnchor: 'auto'},
{offsetPosition: '0% 100%', offsetAnchor: 'auto'},
{offsetPosition: '0% 0%', offsetAnchor: 'auto'}
];
var timingA = {duration: 4000, iterations: Infinity, iterationStart: 0};
var timingB = {duration: 4000, iterations: Infinity, iterationStart: 0.25};
var timingC = {duration: 4000, iterations: Infinity, iterationStart: 0.50};
var timingD = {duration: 4000, iterations: Infinity, iterationStart: 0.75};
targetA.animate(keyframes, timingA);
targetB.animate(keyframes, timingB);
targetC.animate(keyframes, timingC);
targetD.animate(keyframes, timingD);
</script>