-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
136 lines (119 loc) · 4.34 KB
/
index.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>GPS Heatmap Animation</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<style>
body {
margin: 0;
padding: 0;
background: #210029;
}
#animate svg {
width: 100%;
height: 100%;
}
#animate svg path:hover {
stroke: white;
opacity: 1;
}
.octocat {
position: absolute;
top: 15px;
right: 15px;
}
.octocat:hover path {
fill: white;
opacity: 1;
stroke: none;
}
</style>
</head>
<body>
<a href="http://github.com/andytlr/gps-heatmap-animation">
<svg version="1.1" class="octocat" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="40px" height="40px" viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve">
<path fill="none" d="M19.983,2.499C10.046,2.744,2.739,10.221,2.5,20.389c0.137,8.002,4.882,14.466,11.952,16.982
c0.854,0.14,1.195-0.349,1.195-0.873l-0.034-3.32c-2.356,0.384-3.961,0.175-4.746-0.629c-0.82-0.803-1.195-1.293-1.127-1.467
c-0.444-1.013-0.854-1.712-1.264-2.097c-0.444-0.384-0.648-0.559-0.682-0.524c-1.4-1.083-0.102-1.118,0.136-1.083
c0.854,0.14,1.536,0.454,1.98,0.978s0.682,0.803,0.682,0.873c1.673,2.551,3.995,2.097,5.088,1.502
c0.171-1.153,0.614-1.957,1.127-2.376c-4.063-0.279-7.786-2.167-7.956-8.84c0-1.957,0.682-3.564,1.809-4.787
c-0.136-0.245-0.239-0.769-0.341-1.607c-0.102-0.838,0.068-1.887,0.512-3.145c0-0.07,0.375-0.07,1.161,0.035
c0.786,0.105,1.98,0.734,3.654,1.817c1.434-0.384,2.902-0.594,4.405-0.594c1.468,0,2.937,0.21,4.337,0.594
c1.673-1.083,2.868-1.712,3.654-1.817c0.786-0.105,1.161-0.105,1.161-0.035c0.444,1.258,0.614,2.307,0.512,3.145
s-0.205,1.362-0.341,1.607c1.127,1.258,1.809,2.831,1.809,4.787c-0.171,6.709-3.927,8.56-7.99,8.84
c0.648,0.559,1.195,1.642,1.195,3.32l-0.034,4.926c0,0.524,0.341,1.013,1.195,0.873c7.068-2.515,11.814-8.979,11.951-16.981
C37.261,10.326,29.92,2.744,19.983,2.499z"/>
</svg>
</a>
<!-- Make a container for the SVG to append to -->
<div id="animate">
<div id="svgContainer"></div>
</div>
<!-- Append the SVG to the above container -->
<script>
xhr = new XMLHttpRequest();
xhr.open("GET","source-data/Rplots.svg",false);
// xhr.open("GET","source-data/Rplots-lots.svg",false);
xhr.overrideMimeType("image/svg+xml");
xhr.send("");
document.getElementById("svgContainer")
.appendChild(xhr.responseXML.documentElement);
</script>
<!-- Include D3 -->
<script src="vendor/js/d3.v3.min.js" charset="utf-8"></script>
<!-- Octocat specific junks -->
<script>
var octocat = d3.select(".octocat path");
octocat.each(function (d, i) {
var octocatLength = this.getTotalLength();
var path = d3.select(this)
.attr("opacity", "1")
.attr("stroke-dasharray", octocatLength + " " + octocatLength)
.attr("stroke-dashoffset", octocatLength)
.attr("stroke", "white")
.attr("fill", "#210029")
.attr("stroke-width", "1")
.transition()
.duration(3000)
.delay(0)
.ease("linear")
.attr("stroke-dashoffset", 0)
path
.attr("stroke", "purple")
.attr("fill", "purple")
.attr("opacity", "0.5")
});
</script>
<!-- Configure D3 -->
<script type="text/javascript">
// Speed of animation is defined by the length of the paths.
// 1 is fast, 20 is quite slow. Choose a speed somewhere in the middle:
var speed = 6
var paths = d3.selectAll("#animate path");
var previousLength = 0
paths.each(function (d, i) {
var totalLength = this.getTotalLength();
var path = d3.select(this)
.attr("stroke-dasharray", totalLength + " " + totalLength)
.attr("stroke-dashoffset", totalLength)
.attr("stroke", "white")
.attr("opacity", "1")
.attr("fill", "none")
.attr("stroke-width", "0.25")
.transition()
.duration(totalLength * speed)
.delay(previousLength * speed)
.ease("linear")
.attr("stroke-dashoffset", 0)
path
// These are the "transition to" attributes.
// Seems hacky, but lolol?
.attr("stroke", "purple")
.attr("opacity", "0.3")
previousLength = previousLength + totalLength
});
</script>
</body>
</html>